Question : The following SAS program is submitted: data work.accounting; set work.dept1 work.dept2; run; A character variable named JOBCODE is contained in both the WORK.DEPT1 and WORK.DEPT2 SAS data sets. The variable JOBCODE has a length of 5 in the WORK.DEPT1 data set and a length of 7 in the WORK.DEPT2 data set. Which one of the following is the length of the variable JOBCODE in the output data set?
Explanation: The "set statement" takes the length of the common variable, as the length of that variable in the first dataset of set statement.
The length of a variable always define automatically in the first statement and remain unchanged during the whole program until and unless we redefine it.
So when DEPT1 is set the lenght will set to 5 and remail unchanged during the data step
Question : The following SAS DATA step is submitted: data work.accounting; set work.department; length jobcode $ 12; run; The WORK.DEPARTMENT SAS data set contains a character variable named JOBCODE with a length of 5. Which one of the following is the length of the variable JOBCODE in the output data set?
Explanation: This is the log error after we run this program.
/* WARNING: Length of character variable has already been set. Use the LENGTH statement as the very first statement in the DATA STEP to declare the length of a character variable. */ The base dataset has already the length set as 5 if you try to reset after set statement it gives you a warning.
Question : Which one of the following SAS statements renames two variables?
1. set work.dept1 work.dept2(rename = (jcode = jobcode) (sal = salary)); 2. set work.dept1 work.dept2(rename = (jcode = jobcode sal = salary)); 3. Access Mostly Uused Products by 50000+ Subscribers work.dept2(rename = jcode = jobcode sal = salary); 4. set work.dept1 work.dept2(rename = (jcode jobcode) (sal salary));