Desktop productivity for business analysts and programmers

change variable name by keeping same dataset name

Reply
Regular Contributor
Posts: 220

change variable name by keeping same dataset name

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...


Regular Contributor
Posts: 220

Re: change variable name by keeping same dataset name

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

Super Contributor
Posts: 1,636

Re: change variable name by keeping same dataset name

Yes, it is correct.

Occasional Contributor
Posts: 9

Re: change variable name by keeping same dataset name

yes, this is correct!

Super User
Posts: 19,193

Re: change variable name by keeping same dataset name

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;

Ask a Question
Discussion stats
  • 4 replies
  • 230 views
  • 0 likes
  • 4 in conversation