BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
dpine4
Calcite | Level 5

How do I creatae a new sas dataset from one like the following:

HAVE:

x1x2x3y1y2y3y4
abc33.729.234.431.4

 

WANT:

x1x2x3y
abc33.7
abc29.2
abc34.4
abc31.4
1 ACCEPTED SOLUTION

Accepted Solutions
r_behata
Barite | Level 11
data have;
input x1 $	x2	$ x3 $	y1	y2	y3	y4;
cards;
a b c 33.7 29.2 34.4 31.4
run;

data want;
	set have;

	array _y[*] _numeric_;

	do _n_= 1 to dim(_y);
		y=_y[_n_]; output;
	end;

	drop y1 - y4;
run;

View solution in original post

3 REPLIES 3
novinosrin
Tourmaline | Level 20


data have;
input (x1	x2	x3) ($)	y1	y2	y3	y4;
cards;
a	b	c	33.7	29.2	34.4	31.4
;

proc transpose data=have out=want(drop=_name_ rename=col1=y);
by x1-x3;
var y1-y4;
run;

 
r_behata
Barite | Level 11
data have;
input x1 $	x2	$ x3 $	y1	y2	y3	y4;
cards;
a b c 33.7 29.2 34.4 31.4
run;

data want;
	set have;

	array _y[*] _numeric_;

	do _n_= 1 to dim(_y);
		y=_y[_n_]; output;
	end;

	drop y1 - y4;
run;
dpine4
Calcite | Level 5
THANK YOU!

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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