DATA Step, Macro, Functions and more

type conversion error

Reply
Occasional Contributor
Posts: 8

type conversion error

The following SAS program is submitted:
data work.retail;
cost = `20000';
total= .10* cost
run;
What is the result?
A. The value of the variable TOTAL in the output data set is 2000. No messages are written to the SAS log.
B. The value of the variable TOTAL in the output data set is 2000. A note that conversion has taken place is
written to the SAS log.
C. The value of the variable TOTAL in the output data set is missing. An error message is written to the SAS
log.
D. The variable TOTAL in the output data set has no value. The program fails to execute due to a syntax error.
Super User
Posts: 10,505

Re: type conversion error

I suspect that you are going through either certification training materials or some other training. But you should at least have a specific question of  your own abou the posed question.

Maybe something like: I thought the result would be X because of "some idea" but the result is Y? Why is it not Y?

 

 

The "answer" will be in the data set.

Run the code, examine the log and then proc print data=work.retail; run;

 

Note: Posting such things into the body of the forum may reformat code so that what is seen in your post is not the actual code you started with. Post code into a code box opened with the {i} icon in the forum message menu bar.

 

 

Super User
Posts: 10,505

Re: type conversion error

See if anything from my response to https://communities.sas.com/t5/Base-SAS-Programming/value-of-variable/m-p/341363 looks familiar here.

Super User
Posts: 5,085

Re: type conversion error

Is it really easier to post a question here, than to paste the code into the Program Editor and run it?

 

Assuming you posted the code correctly, the answer is "D".  There is a missing semicolon just before the RUN; statement, so you get a syntax error.

 

It's worth learning what happens if you were to add the semicolon.  Try testing it that way.

Ask a Question
Discussion stats
  • 3 replies
  • 168 views
  • 1 like
  • 3 in conversation