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!

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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