DATA Step, Macro, Functions and more

Is the Answer Key correct? VALIDVARNAME=ANY

Reply
Occasional Contributor
Posts: 19

Is the Answer Key correct? VALIDVARNAME=ANY

Hi,

 

My answer is E to the question below but SAS answer key is C.

 

With the system option VALIDVARNAME=ANY, which of the following variable names is valid?

a. 4BirthDate

b. $Cost

c. _Items_

d. Tax-Rate

e. All of the above

 

According to the definition, I believe that a, b, and d are all valid names. Can someone let me know why E is not a correct answer?

 

Thanks.

Eric

Super User
Posts: 10,258

Re: Is the Answer Key correct? VALIDVARNAME=ANY

Posted in reply to ericliuzh1

The other names would only be valid if they were enclosed in '...'n and therefore name literals.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Occasional Contributor
Posts: 19

Re: Is the Answer Key correct? VALIDVARNAME=ANY

Posted in reply to KurtBremser

Thanks, Kurt. It makes sense now!

SAS Super FREQ
Posts: 4,242

Re: Is the Answer Key correct? VALIDVARNAME=ANY

Posted in reply to ericliuzh1

I can see why you are confused. I suggest you re-read the section of your study guide that deals with VALIDVARNAME and n-literals to see if it makes a distinction between those two concepts. You are correct that all of the variables are valid if you use them as n-literals such as

data _null_;

'4BirthDate'n = 1;
'$Cost'n = 2;
_Items_ = 3;
'Tax-Rate'n = 4;

run;

 

However, C is the only variable name that you can use without embedding the name into an n-literal, as shown.

 

Occasional Contributor
Posts: 19

Re: Is the Answer Key correct? VALIDVARNAME=ANY

Thanks for the examples! I got it now!

Ask a Question
Discussion stats
  • 4 replies
  • 94 views
  • 0 likes
  • 3 in conversation