ElearnSAS.com

ElearnSAS.com
SAS Learning Platform

Base SAS 42

The following SAS program is submitted:
data work.retail;
cost = '20000';
total = .10 * cost;
run;
Which one of the following is the value of the variable TOTAL in the output data set?
A. 2000
B. '2000'
C. . (missing numeric value)
D. ' ' (missing character value)
Click Comment link to get answer

39 comments:

  1. Correct answer is 'A'

    ReplyDelete
  2. Anonymous4:19 PM

    Answer is 'A'

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
  3. Anonymous12:26 PM

    c, because cost is a character variable.

    ReplyDelete
    Replies
    1. in this case
      SAS will convert char values to numeric
      here's the log output :
      NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).
      3:15

      Delete
  4. Hi - first of all let me thank you for taking all the efforts in bringing together all this, for the benefit of ppl like me who are planning to take up the cert exam.
    I would really appreciate if you could please remove the conflicting answers from the list and also add in the comments as to why it should be the correct answer and the others.

    ReplyDelete
    Replies
    1. while calculating total cost 20000 will be autoconverted to numeric value because it is standard numeric datatype it can be calculated simply,
      20000*0.1=2000

      Delete
  5. swapna6:43 PM

    The answer is A.
    to an extent, SAS automatically converts character to numeric. eben though cost is character. due to automatic conversion
    here we are getteng 2000

    ReplyDelete
  6. Anonymous3:43 PM

    Answer is C

    ReplyDelete
  7. Answer is 'A'
    Because the character value is automaticaly converted to numberic by SAS.

    Here's the log results
    "NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column)"

    ReplyDelete
    Replies
    1. yes this is correct
      got the same result myself
      Character values have been converted to numeric values at the places given by: (Line):(Column).
      3:15
      NOTE: The data set WORK.RETAIL has 1 observations and 2 variables.

      Delete
  8. sreelakshmi12:27 AM

    ans is "D"

    ReplyDelete
  9. Answer is 'A'

    Same reason as Prashant...
    Character values have been converted to numeric values at the places given by: (Line):(Column)

    ReplyDelete
  10. The answer is 'A' I tried it.

    ReplyDelete
  11. Anonymous8:42 AM

    Just ran the program in sas, the correct answer is A, cost is automatically converted to numeric.

    ReplyDelete
  12. Anonymous6:47 PM

    Yes; SAS log will give you comment on automatic conversion.
    What if it was like this "20000"; still able to convert?

    ReplyDelete
  13. Anonymous5:06 AM

    @ SWAPNA ... U R right swapna sas will take auto conversions

    ReplyDelete
  14. Answer is A. When valid operators are used, SAS automatically converts character variables with numbers to numeric and provides the answer in numeric 'BEST12.' format with length of default 8 bytes.

    Log reads:

    NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).
    505:15
    NOTE: The data set WORK.RETAIL has 1 observations and 2 variables.

    ReplyDelete
  15. Hi Guys,
    To avoid seeing this message in log- Character values have been converted to numeric values at the places given by:
    (Line):(Column).

    You can explicitly convert the character values of char variable (in this case cost to numeric values by using the INPUT function.)
    use informat with input. here informat is 5 becoz 20000 value:
    use this prgm- msg will disappear from log. as a good programmer, your log be clear.
    data work.retail;
    cost = '20000';
    total = .10 * cost;
    run; *char values converted to num in log- to avoid this msg, give input stmt;

    data work.retail1;
    cost = '20000';
    cost1= input (cost, 5.);
    total = .10 * cost1;
    run;
    Hope it helps.

    ReplyDelete
  16. Anonymous11:49 AM

    0.10 is Numeric: Hence
    20000*.10 = 2000;

    hence answer is 'A'

    ReplyDelete
  17. Anonymous3:58 PM

    Variable Type Len Pos
    ---------------------
    name Char 8 0
    salary Char 8 16
    status Char 8 8



    name status salary
    ----------------------
    Liz S 15,600
    Herman S 26,700
    Marty S 35,000

    The following SAS program is submitted:

    proc print data=work.salaries;
    where salary<20000;
    run;

    What is displayed in the SAS log after the program is executed?

    a. A NOTE indicating that 1 observation is read.
    b. A NOTE indicating that 0 observations were read.
    c. A WARNING indicating that character values have been converted to numeric values.
    d. An ERROR indicating that the WHERE clause operator requires compatible variables.

    why not choose c?

    ReplyDelete
  18. Someone can let me know, when SAS automatically converts character to numeric. Base on what kind of condition?

    ReplyDelete

  19. 56 data work.retail;
    57 cost = '20000';
    58 total = .10 * cost;
    59 run;

    NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).
    58:15
    NOTE: The data set WORK.RETAIL has 1 observations and 2 variables.
    NOTE: DATA statement used (Total process time):
    real time 0.01 seconds
    cpu time 0.02 seconds
    ans is 2000

    ReplyDelete
  20. Really cool post, highly informative and professionally written and I am glad to be a visitor of this perfect blog, thank you for this rare info!
    SAS Online Training

    ReplyDelete
  21. Anonymous1:08 PM

    Here's an interesting variation.

    data work.retail;
    total = '';
    total = .10 * 2000 ;

    proc print data=work.retail;
    run;

    ReplyDelete
  22. Anonymous1:12 PM

    I should point out that the 0.1 does not force total to be numeric. It's the * operator.

    ReplyDelete
  23. Anonymous10:21 PM

    Run the following code:
    data work.retail;
    cost = '20000';
    total = .10 * cost;
    run;

    The value 2000 will be assigned to Total and log will say the following
    NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).

    Hence the answer is A

    ReplyDelete
  24. Anonymous11:48 AM

    Mumbai Railway will release RRB Mumbai Group D result on official railway website. Mumbai Railway Group D Cutoff mark is also announced. The RRB Mumbai Railways Group D exams got over. Over 2 Crore candidates are written the exam. The most awaited RRB Mumbai Group D CBT1 Results 2018 will be released soon. The candidates who are all wrote RRB Group D CBT1 for the Indian Railway Helper, Gateman, Trackman, Porter, Track Maintainer, Pointsman and Hospital Attendant recruitment can only able to download Mumbai RRB Group D result Selection list pdf.

    ReplyDelete
  25. thanks to the admin to for this kind of post you can get the latest freejobalert updates

    ReplyDelete