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
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.