BookmarkSubscribeRSS Feed
wendy_sasuser
Calcite | Level 5

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.

1 REPLY 1
Linlin
Lapis Lazuli | Level 10

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

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.

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
  • 1 reply
  • 947 views
  • 0 likes
  • 2 in conversation