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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

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