Hi, i have one column named 9-24 . Is there a way to use is in a "keep" statement? I'm new to SAS and all the ways I tried failed as it's considered a range from 9 to 24.
Keep '19-24'n
Wrap each variable you want to keep in a single quote followed by an n.
'VARIABLE'n
Are you trying to import variable from other source into SAS? Can you please show log?
Just merging 2 datasets.
So variable name is 9-24 and this is in SAS dataset?
yes
What is the error message? Variable name does not conform to SAS naming conventions.
ERROR 214-322: Variable name 19 is not valid
It was imported from excell.
"9-24" is the label of the imported variable. It is not a valid SAS variable name, so it was replaced with "__24" (two underscores). You can use (keep=__24).
PG
If you can change variable name in excel then do that. SAS variable name must begin with a letter (A-Z, either uppercase or lowercase) or an underscore (_).
Didn't work. I'm using" options validvarname=any" if that helps
Try
KEEP '9'n-'24'n.
ERROR: Not all variables from the list '9'n-'24'n have been found
Try double dash instead of single dash. If that doesn't work, please post the results from proc contents on your dataset.
proc contents data=have; run;
Keep '19-24'n
Wrap each variable you want to keep in a single quote followed by an n.
'VARIABLE'n
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.
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.