BookmarkSubscribeRSS Feed
Jodifer77
Fluorite | Level 6

Can someone help me understand how the code is processing the output in the attached table? 

 

data number;
array member[*] mem1-mem12;
mem1=10;
do id=1 to dim(member)-3;
   member[id+1]=id/member[id];
   output;
   end;
run;

 

 

 

4 REPLIES 4
justusjillella
Fluorite | Level 6
Hi, dim(MEMBER) returns 12 as there are 12 elements in the array

The do loop resolves to
Id=1 to 9
During the first iteration
Mem(id+1) resolves to membe[2] which is nothing but mem2 variable
Mem2=1/10 and this variable is written to the output dataset

This step is iterated till member[9] which is mem9 variable according to the array
Jodifer77
Fluorite | Level 6

Thanks for the feedback!  I didn't understand where the denominator was coming from, but I think I do now.  The denominator is the result of the previous iteration's calculation, right?

 

Thanks!

Astounding
PROC Star
Give us somewhere to begin.

Do you know what the DATA statement does?

Do you know what the END statement does?

Do you know what the OUTPUT statement does?

Do you know what the ARRAY statement does?

Have you printed and examined the results?
Jodifer77
Fluorite | Level 6

Thanks for you time in responding.  It was my first question posted...

 

My question was in the iterative do loop, I didn't know where the denominator for the member[id+1]=id/member[id] was coming from.  I was able to figure it out that it was the value calculated in the previous iteration.  I think I'm good to go.

 

Thanks!

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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