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

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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