All,
This is probably a simple way to achieve what I want but I don't know how to do this.
I am importing some data from a csv file using the following code:
proc import datafile=csv out=System dbms=csv replace;
/* getnames=yes; */ *since imported names have parantheses or special characters;
run;
As shown in the commented code, I have tried commenting the options of getnames out and tried it with the code turned on. Either ways the imported data set has variables that are not being recognized with the rename option.
When attempting to rename :
data Test1;
set Work.System(rename = System Power Output(W) = SystemPowOutInW);
Run;
data Test1;
set Work.System(keep = System Power Output(W) = SystemPowOutInW);
Run;
Set the following option and rerun your import code.
Options validvarname=V7;
SAS should automatically convert the names into cleaner names.
When column names are imported that do not conform to the SAS standard then you can rename them like this:
data Test1;
set Work.System(rename = ('System Power Output(W)'n = SystemPowOutInW));
Run;
Set the following option and rerun your import code.
Options validvarname=V7;
SAS should automatically convert the names into cleaner names.
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.
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.