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

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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