BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
trapinka
Calcite | Level 5

This is question 5 from Chapter 2 SAS Certification Prep Guide, edition 2018

5. 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

 

My answer is e.


Answer from the book

Correct answer: c
Variable names follow the same rules as SAS data set names. They can be 1 to 32 characters long, must begin with a letter (A-Z, either uppercase or lowercase) or an underscore, and can continue with any combination of numbers, letters, or underscores.

It seems that in the explanation missed VALIDVARNAME option, which is set to ANY. That means that there are no SAS rules to apply for variables names. Can you clarify the correct answer?

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi:

  This is addressed in the errata or content update for the 4th edition, as shown here:

https://support.sas.com/en/books/content-updates-base-prep-guide-4th-edition.html

 

  Look for Appendix 1 update. page 528, question 5.

 

Cynthia

View solution in original post

10 REPLIES 10
Tom
Super User Tom
Super User

I would say that C is technically correct since the others would require the use of a name literal and not the value as shown.

 

Try this code.

data test;
  length 4BirthDate $Cost _Items_ Tax-Rate 8 ;
run;
data test;
  length '4BirthDate'n '$Cost'n _Items_ 'Tax-Rate'n 8 ;
run;
proc contents data=test;
run;

But that is one poorly worded question. 

E could reasonable be seen as the correct answer since this is what PROC CONTENTS shows.

image.png

A better question would include at least one value using a name literal to make it clearer what the list represented. Or a value that is illegal even using VALIDVARNAME=ANY, such as one that is all blanks or includes a null byte ('00'x).  Then which answer was correct would NOT depend on how the user interpreted the meaning of the list.

Cynthia_sas
SAS Super FREQ

Hi:

  This is addressed in the errata or content update for the 4th edition, as shown here:

https://support.sas.com/en/books/content-updates-base-prep-guide-4th-edition.html

 

  Look for Appendix 1 update. page 528, question 5.

 

Cynthia

Tom
Super User Tom
Super User

@Cynthia_sas wrote:

Hi:

  This is addressed in the errata or content update for the 4th edition, as shown here:

https://support.sas.com/en/books/content-updates-base-prep-guide-4th-edition.html

 

  Look for Appendix 1 update. page 528, question 5.

 

Cynthia


That correction does NOT actually fix the problems with the question. It just changes the answer to one that assumes the list of names it like what you would see in PROC CONTENTS output instead of what you would use in SAS code.  The question is left uncorrected.

Cynthia_sas
SAS Super FREQ
Tom:
Thanks for the feedback. I'll ask the Certification editors to take a look at the specific question.
Cynthia
sabisw
SAS Employee

@Tom, thank you for your feedback. We can look into updating this question for our next release.

 

However, the question is asking when you use VALIDVARNAME=ANY which of names are valid. Yes, you can do it with name literal, but you must also declare

options validvarname=any

for it to work. This may be dependent upon which SAS environment you are using. For Windowing Environment, the default is set to VALIDVARNAME=V7. 

 

 

If you do not set VALIDVARNAME=ANY in the OPTIONS statement then the following:

 

data test;
	length 4BirthDate $Cost _Items_ Tax-Rate 8;
run;
proc contents data=test;
run;

 

 

results in an error in the log that, 4BirthDate is not a valid SAS name. 

 

However, in order for it to work you must declare options VALIDVARNAME=ANY and use name literal like below:

 

options validvarname=any;
data test01;
   length '4BirthDate'n '$Cost'n '_Items_'n 'Tax-Rate'n 8;
run;
proc contents data=test01;
run;

 

 

I tried the same thing in SAS Studio and without the

options validvarname=any

and it gave me the same error and then I did it with the options statement and declaring a name literal, and then I got the correct answer. 

 

 

Base SAS is shipped with the system options being set to VALIDVARNAME=V7 and SAS Viya is shipped with the system options being set to VALIDVARNAME=ANY. 

 

Here is a link to the documentation for more information: VALIDVARNAME=ANY System Option

 

I hope this helps and clarifies a bit more.

 

-Samantha

Tom
Super User Tom
Super User

Thanks @sabisw for your reply. And for proving my point.

The issue with the question is not really whether the names are valid, but whether the question is clear.

 

The names as listed in the question might be valid names, but they are not valid names for use in actual SAS code.

So whether C or E is the right answer depends on how the user interprets the question. 

Therefore the question needs to be fixed to eliminate that ambiguity.

 

2    options validvarname=any;
3    data test;
4    	length 4BirthDate $Cost _Items_ Tax-Rate 8;
             -
             22
ERROR 22-322: Syntax error, expecting one of the following: a name, _ALL_, _CHARACTER_, _CHAR_,
              _NUMERIC_.

4  ! 	length 4BirthDate $Cost _Items_ Tax-Rate 8;
                           ----
                           22
ERROR: Alphabetic prefixes for enumerated variables (Tax-Rate) are different.
ERROR 22-322: Expecting a numeric constant.

5    run;

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.TEST may be incomplete.  When this step was stopped there were 0
         observations and 3 variables.

 

sabisw
SAS Employee

@Tom, Correct they are not valid SAS names therefore you have to use VALIDVARNAME=ANY and declare them as a name literal. That's the reason why without the VALIDVARNAME=ANY it doesn't work.

Tom
Super User Tom
Super User

@sabisw wrote:

@Tom, Correct they are not valid SAS names therefore you have to use VALIDVARNAME=ANY and declare them as a name literal. That's the reason why without the VALIDVARNAME=ANY it doesn't work.


Great, so you will have someone re-word the question to remove the ambiguity?

 

Cynthia_sas
SAS Super FREQ
Hi:
Well, I would have liked it if the option had been named:
VALIDVARNAME_WHEN_USED_AS_NAME_LITERAL
or made it:
VALIDVARNAME=ANY_AS_NAME_LITERAL -- but they didn't ask me for input into the option name.
Sigh.
Cynthia
Tom
Super User Tom
Super User

The fact that name literals are required is part of what makes the question poor. It basically is penalizing test takers that understand SAS too well.

 

 

 

Welcome to the Certification Community

 

This is a knowledge-sharing community for SAS Certified Professionals and anyone who wants to learn more about becoming SAS Certified. Ask questions and get answers fast. Share with others who are interested in certification and who are studying for certifications.To get the most from your community experience, use these getting-started resources:

Community Do's and Don'ts
How to add SAS syntax to your post
How to get fast, helpful answers

 

Why Get SAS Certified.jpg

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 10 replies
  • 4665 views
  • 2 likes
  • 4 in conversation