DATA Step, Macro, Functions and more

validvarname

Accepted Solution Solved
Reply
Contributor
Posts: 46
Accepted Solution

validvarname

Hello all,

As in sas, names begin with letter(lowe or upercase) or (_) but I want to use 2$adc2_    as my data set name and using (validvarname=any) .Where validvarname=any should be placed in a data step to make this name(2$adc2_) valid?below is my sas code. any help is appreciated.


data 2$adc2_ ; validvarname=any;
infile datalines;
input score1 score2 score3;
datalines;
90 80 98
78 88
65 66 69
92 94 96
;
run;
proc print data=2$adc2_;run;


Accepted Solutions
Solution
‎02-15-2018 09:38 PM
Super User
Super User
Posts: 8,125

Re: validvarname


fatemeh wrote:

do you mean i should replace  validvarname with validMEMname? below is my sas code still giving me errorMan Sad

 

options validMEMname=any;
data '2$adc2_'n;
infile datalines;
input score1 score2 score3;
datalines;
90 80 9878 8865 66 6992 94 96
;
proc print data='2$adc2_'n;
run;


And did you read the error?

39    options validmemname=any ;
              ------------
              14

ERROR 14-12: Invalid option value any for SAS option VALIDMEMNAME.

Did you look at the documentation for that option?

http://documentation.sas.com/?docsetId=nlsref&docsetTarget=n10nwm6blrcrtmn0zdcwyxlwxfjh.htm&docsetVe...

image.png

Or read the previous replies to your topic?

image.png

 

View solution in original post


All Replies
Super User
Posts: 23,773

Re: validvarname

VALIDVARNAME is an option, not on the data set but globally.

 

options validvarname = any;

data ....
Super User
Super User
Posts: 8,125

Re: validvarname

The VALIDVARNAME=ANY only applies to variable names, not member names.

Try VALIDMEMNAME=EXTEND.

 

Also make sure to use a name literal if you name does not follow normal naming conventions.

options validmemname=extend ;

data 'really$bad name'n ;
  x=1;
run;

proc contents; run;
SAS Super FREQ
Posts: 503

Re: validvarname

This is the correct placement of the option.  It will not handle member names like yours.

options validvarname=any;
data '2$adc2_'n;
infile datalines;
input score1 score2 score3;
datalines;
90 80 98
78 88
65 66 69
92 94 96
;

proc print data='2$adc2_'n;run; proc print data=2$adc2_;run;
Contributor
Posts: 46

Re: validvarname

Posted in reply to WarrenKuhfeld

thanks for your reply .still sas is giving me error for both validvarname=any and validvarname=extend  Man Sad

Super User
Super User
Posts: 8,125

Re: validvarname

Copy the lines from the SAS log and paste them into the forum.

Make sure to use the {i} icon to pop-up a code window to paste the text to avoid having the forum editor reformat the text.

 

Contributor
Posts: 46

Re: validvarname

options validvarname=any;
56 data '2$adc2_'n;infile datalines;input score1 score2 score3;datalines;

ERROR: The value '2$ADC2_'n is not a valid SAS name.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

56 ! 90 80 9878 8865 66 6992
--
180
56 ! 94 96;proc print data='2$adc2_'n;run;

ERROR 180-322: Statement is not valid or it is used out of proper order.

ERROR: The value '2$ADC2_'n is not a valid SAS name.

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds

 

58 proc print data=2$adc2_;run;
-
22
200
ERROR: File WORK.ADC2_.DATA does not exist.

ERROR 22-322: Expecting a name.

ERROR 200-322: The symbol is not recognized and will be ignored.

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds

Super User
Super User
Posts: 8,125

Re: validvarname

You are still trying to change the wrong option.  validVARname is for VARiable names. You are trying to use dataset (member) name that contains gibberish characters. To do that you need to change the validMEMname option.

Contributor
Posts: 46

Re: validvarname

do you mean i should replace  validvarname with validMEMname? below is my sas code still giving me errorMan Sad

 

options validMEMname=any;
data '2$adc2_'n;
infile datalines;
input score1 score2 score3;
datalines;
90 80 9878 8865 66 6992 94 96
;
proc print data='2$adc2_'n;
run;

Solution
‎02-15-2018 09:38 PM
Super User
Super User
Posts: 8,125

Re: validvarname


fatemeh wrote:

do you mean i should replace  validvarname with validMEMname? below is my sas code still giving me errorMan Sad

 

options validMEMname=any;
data '2$adc2_'n;
infile datalines;
input score1 score2 score3;
datalines;
90 80 9878 8865 66 6992 94 96
;
proc print data='2$adc2_'n;
run;


And did you read the error?

39    options validmemname=any ;
              ------------
              14

ERROR 14-12: Invalid option value any for SAS option VALIDMEMNAME.

Did you look at the documentation for that option?

http://documentation.sas.com/?docsetId=nlsref&docsetTarget=n10nwm6blrcrtmn0zdcwyxlwxfjh.htm&docsetVe...

image.png

Or read the previous replies to your topic?

image.png

 

SAS Super FREQ
Posts: 503

Re: validvarname

Did you n-literalize my names (as I did in my example), which for some reason stripped out the line feeds.

Contributor
Posts: 46

Re: validvarname

[ Edited ]
Posted in reply to WarrenKuhfeld

thanks for your reply. I just copied the codes you corrected and pasted it in sas and executed that!

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 11 replies
  • 371 views
  • 4 likes
  • 4 in conversation