By admin | September 25, 2009

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.

7 comments | Add One

  1. admin - 09/25/2009 at 3:26 pm

    B

  2. shilpa - 10/4/2011 at 5:55 pm

    Can some one explain why the ans is B.

    Thanks

  3. Jigar - 12/25/2012 at 10:07 am

    answer shud be option a.
    y option b. ???

    plz explain

  4. sunny - 08/31/2013 at 9:24 pm

    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

  5. Khai Ming - 11/13/2013 at 5:28 pm

    Product_Number was automatically converted by SAS with FORMAT: BEST12. to character value. Thesewhy we see empty spaces.

  6. hh - 02/19/2014 at 8:52 am

    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.

  7. Lili - 07/25/2014 at 9:29 am

    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.

Leave a Comment

Leave a Reply

Your email address will not be published.