BookmarkSubscribeRSS Feed
JohnT
Quartz | Level 8
Hi,

I have some data in which I want to conver the value of some variables into new variables.

Here's some data:
[pre] data tmp;
input AMT01 AMT02 AMT03 AMT04 CODE01 $ CODE02 $ CODE03 $ CODE04 $;
datalines;
100 200 500 400 AB CD EF GH
100 200 500 400 AB CD IJ KL
100 200 500 400 AB EF IJ KL
;
run;[/pre]

And here's how the table looks:
[pre] AMT01 AMT02 AMT03 AMT04 CODE01 CODE02 CODE03 CODE04
100 200 500 400 AB CD EF GH
100 200 500 400 AB CD IJ KL
100 200 500 400 AB EF IJ KL[/pre]

Here's how I want that data to look:
[pre] AB CD EF GH IJ KL
100 200 500 400 . .
100 200 . . 500 400
100 . 200 . 500 400[/pre]

Is there some simple method of creating the variable names without using macros? Hopefully with a function?


Thanks. Message was edited by: John T
2 REPLIES 2
NickR
Quartz | Level 8
data tmp1;
length code $8;
set tmp;
ord=_n_;
amt=amt01;
code=code01;
output;
amt=amt02;
code=code02;
output;
amt=amt03;
code=code03;
output;
amt=amt04;
code=code04;
output;
run;

proc transpose data=tmp1 out=tmp2(drop=ord _name_);
id code;
var amt;
by ord;
run;
JohnT
Quartz | Level 8
Hi Nick R,

Thanks for your suggestion.

That works for me, now to integrate it into my job.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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