Hi Everyone,
Very new to sas. I just imported a csv file and was wondering how I can rename a column. Thanks for your help. This was my code:
data pracitce.new1 (rename=(nationalid=nid));
set practice.new
run;
proc print data= practice.new1;
run;
The imported file is now under practice.new. Is there a way to just modify the column on the parent file without creating a new file? I got this error:
98 data pracitce.new1 (rename=(nationalid=nid));
ERROR: Libref PRACITCE is not assigned.
99 set practice.new
100 run;
ERROR: File WORK.RUN.DATA does not exist.
101
NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
102 proc print data= practice.new1;
103 run;
NOTE: No observations in data set PRACTICE.NEW1.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
You did not assign your libref PRACITCE right 🙂
Your rename statement looks right if you want to use the variable name nid in your data step.
If you want to use the variable name nationalid and then rename the variable in your output data set simply do
data pracitce.new1;
set practice.new
rename nationalid=nid
run;
Thank you. How do I correctly assign the practice folder as my library? I thought I did that already before when I created the library folder... thanks again.
Like this 🙂
%let path = insertyourpathhere;
libname practice "&path";
As to your question - yes you can rename a variable in a dataset without making a new dataset ... using PROC DATASETS:
proc datasets libname=practice; /*or pracitce if that is correct spelling*/
modify new;
rename nationalid=nid;
run;
quit;
Looks like a typo?
Practice vs pracitce
Yes, it was a typo! Thank you everyone.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.