BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
nat1
SAS Employee

Hi, I have a data set in CSV that looks like the following. T1 - T29 are actually the column names for the data columns that follows at the bottom. 

 

semistructured.JPG

 

How do I use SAS EG to assign the column names (T1, T2, T3, etc) to the columns that i extracted using the import wizard as seen below, instead of the default column names F1, F2, etc?importeddata.JPG

 

Appreciate any input! thanks very much

 

Regards

Nat

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
If you can make a MAP file to display how to rename them, That would be easy.


data map;
input old $ new $;
cards;
F1 T1
F2 T2
;
run;

data _null_;
 set map end=last;
 if _n_=1 then call execute('proc datasets lib=work nolist nodetails;modify have;rename ');
 call execute(catx('=',old,new));
 if last then call execute(';quit;');
run;


View solution in original post

3 REPLIES 3
Ksharp
Super User
If you know the exactly number of variables, that would be easy.

data want;
 set have(rename=(F1-F29=T1-T29));
run;



nat1
SAS Employee

Thanks but the column names are actually the ones hidden in black (for confidentiality purposes), so its not as easy as "T1" and "T2" etc. It looks something like P1TU45S and Q_24FTG, etc.

 

I tried to import that column separately and transpose so I would have a table with a single row where the column name is the same as the data in the first row. I thought it would work if I appended these two tables but it didnt.. furthermore the formats don't match (i.e. column name table has all characters and data table is numeric, hence no match).

 

Any suggestions?

 

Regards,

Nat

Ksharp
Super User
If you can make a MAP file to display how to rename them, That would be easy.


data map;
input old $ new $;
cards;
F1 T1
F2 T2
;
run;

data _null_;
 set map end=last;
 if _n_=1 then call execute('proc datasets lib=work nolist nodetails;modify have;rename ');
 call execute(catx('=',old,new));
 if last then call execute(';quit;');
run;


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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 3 replies
  • 765 views
  • 0 likes
  • 2 in conversation