BookmarkSubscribeRSS Feed
sas_9
Obsidian | Level 7

Hi all,

I have 3 var,

VAR1  VAR2  VAR3 in dataset name A

want to change VAR1=FILEID VAR2=SUTSAB VAR3=ID by keeping dataset name same, A..

what code should look like?

Thanks...


4 REPLIES 4
sas_9
Obsidian | Level 7

is this is correct -  i don't have SAS with me so just want to make sure

data a;

set work.a;

rename var1=fileid var2=stusab var3=id;

run;

Thanks

Linlin
Lapis Lazuli | Level 10

Yes, it is correct.

elfkitty12
Calcite | Level 5

yes, this is correct!

Reeza
Super User

Yes, but you're basically deleting your old copy and creating a new copy.

If you have a large dataset you may want to use proc datasets to rename the variables in the dataset.

proc datasets library=work;

modify a;

rename VAR1=FILEID VAR2=SUTSAB VAR3=ID;

quit;

sas-innovate-white.png

Missed SAS Innovate in Orlando?

Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.

 

Register now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1363 views
  • 0 likes
  • 4 in conversation