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

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;

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

@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

11 REPLIES 11
Reeza
Super User

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

 

options validvarname = any;

data ....
Tom
Super User Tom
Super User

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;
WarrenKuhfeld
Rhodochrosite | Level 12

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;
fatemeh
Quartz | Level 8

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

Tom
Super User Tom
Super User

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.

 

fatemeh
Quartz | Level 8

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

Tom
Super User Tom
Super User

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.

fatemeh
Quartz | Level 8

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;

Tom
Super User Tom
Super User

@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

 

WarrenKuhfeld
Rhodochrosite | Level 12

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

fatemeh
Quartz | Level 8

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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

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
  • 11 replies
  • 7168 views
  • 4 likes
  • 4 in conversation