SAS Certified Base Programmer 123 Questions (79)
The following SAS program is submitted:
data work.products; Product_Number=5461; Item = '1001'; Item_Reference=Item||'/'||Product_Number; run;
Which one of the following is the value of the variable ITEM_REFERENCE in the output data set?
A. 1001/5461
B. 1001/ 5461
C. . (missing numeric value)
D. The value can not be determined as the program fails to execute due to errors.
Topics:
SAS Base Questions |
7 Comments »
B
Can some one explain why the ans is B.
Thanks
answer shud be option a.
y option b. ???
plz explain
Product_number has length 12 because it was automatically converted from numerals into character by SAS using format best12. also note that ‘1001/’ is of length 5. ‘5461’ has length 4. So there must be 3 spaces between’1001/’ and ‘5461’. This is easier to see if we replace space with periods:
1001/…5461
Product_Number was automatically converted by SAS with FORMAT: BEST12. to character value. Thesewhy we see empty spaces.
When you paste in above code into SAS, you always have leading blanks when the value is numeric while character value does not have any leading/trailing blanks.
I referred to automatic numeric-to-character conversion in SAS online tutor. I guess the reason is that when the numeric is converted to character data automatically, the resulting character is right-aligned. For example, if the original numeric data has fewer than 12 digits, the resulting character will have leading blanks.