BookmarkSubscribeRSS Feed
new810
Calcite | Level 5

So lets say if there are six excel files all containing similar variables names and their own observations, ie. in one excel file the variable name might be Payor Name, Name ID, Assigned Code, where the other excel might say Original Payor Name, Original ID, Proc Code and the third excel might say Original Payer Name, Original Name ID, Code. All have similar variable names that represents the same thing.

And now, I've successfully imported them into SAS and I want to rename the variable names so that they all have a standardized name, i.e. Payor Name, Payor ID, Code and because I am working with six excel files, I thought that it may be conveninet to write a macro that renames all the variable names, and this is where I am currently stuck on...

I'm new to SAS and understand the basics of macro and rename but combining them is my problem even though I feel like it is do-able. please help!

4 REPLIES 4
Tom
Super User Tom
Super User

I doubt that a macro would add much value to this situation.  Unless it was an Excel macro that you gave out to the people supplying you with the data so that the files would be consistently formatted.

Just type the code into your editor and copy and paste it five more times and adjust for the differences.

data all;

set

   one (rename = ('Payor Name'n = payor  "Name ID"n = name "Assigned Code"n = code ))

   two (rename = ('Original Payor Name'n = payor  "Original ID"n = name "Proc Code"n = code )) 

   ........

new810
Calcite | Level 5

Thanks Tom, I guess it is easier to do it that way.. than setting a macro. Thank you!

Reeza
Super User

If the data was all in the same order then you could use PROC SQL Union all or Insert into and the names would be taken from the first file.

proc sql;

create table want as

select * from (

select * from table1

union all

select * from table2) a;

quit;

new810
Calcite | Level 5

Thanks Reeza, I will give that idea a try. Thanks!

SAS Innovate 2025: Register Now

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!

How to Concatenate Values

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 4 replies
  • 1592 views
  • 6 likes
  • 3 in conversation