Hello,
I am doing a simple array procedure to shape a series of wide variables into one long variable. The interesting variable is obtn1, obtn2, obtn3, obtn4, obtn5. After I run the following codes, I got a dataset with a new variable "order=6" for all observations. I have no idea where the '6' came from.
And the new variable obt is almost all " . " even when the original obtn1-obtn5 were quite well filled. Anyone knows what happened here?
Thanks!
data all_year2;
set all_year;
array obt [5] OBTN1 OBTN2 OBTN3 OBTN4 OBTN5;
do order=1 to 5;
obtain=obt [order];
end;
run;
obtn1-obtn5 are numerical variables.
you need an output statement. try the code below:
data all_year;
input OBTN1 OBTN2 OBTN3 OBTN4 OBTN5;
cards;
1 2 3 4 5
6 7 8 9 10
;
data all_year2;
set all_year;
array obt [5] OBTN1 OBTN2 OBTN3 OBTN4 OBTN5;
do order=1 to 5;
obtain=obt [order];
output;
end;
run;
proc print;run;
Linlin
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.