BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I have a column of numbers
2
3
5
6
7
12
11
9
and I want to use them one by one in a do loop. How should I express the dimensions of that array to make the loop read the element of the first row, then the second row, etc...
5 REPLIES 5
ArtC
Rhodochrosite | Level 12
We are almost certainly going to need more information before we can get you a fully satisfactory answer.

The DATA step has an implied loop that processes each row of a table one row at a time.
[pre]
data new;
set old;
......each value is processed one at a time ......
run;
[/pre]
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Using a DATA step, you can load the input data and also use an ARRAY declaration to reference the variable list in a DO I=1 TO DIM(); END; code paragraph. The SAS support http://support.sas.com/ website had SAS-hosted DOC and supplemental technical and conference reference material on the topic.

Scott Barry
SBBWorks, Inc.

Suggested Google advanced search argument, this topic / post:

intro data step programming array site:sas.com
deleted_user
Not applicable
This is what I'm trying to do...

data z.A9 z.B9;
set grades1;
/*This is the data set that contains the array "yr" which is a two dimensional array, rows(24) by columns(6)*/
array yr(6) yr1-yr6;
array f(6);
do n = 1 to 6;

f(n) = quantile('BINOM',yr(n),.5,10);

end;
/* Now in the following loop I want to use the numbers from the first column of the array f*/
/*I don't know how to express the dimensions of the array f in order to use the elements in each row of the array*/


do i=1 to 24;

x3=0;
do j=1 to f(1,i,1)???;
x2=7000+exp(5.12+0.92*rannor(123));
x3=x3+x2;

output z.A9;
** output to B only when J=f(1,i,1) in the inner loop;
if j=f(1,i,1) then x4=x4+x3;
if j=f(1,i,1) then output z.B9;
end;

output z.A9;


end;


run;
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
The SAS Support http://support.sas.com/ website has SAS-hosted DOC and supplemental technical / conference reference material on this topic/post. Here's one example using the site's SEARCH facility:

http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#/documentation/cdl/e...


Scott Barry
SBBWorks, Inc.

Suggested Google advanced search arguments, this topic / post:

dimensional array site:sas.com

introduction array site:sas.com

dim function site:sas.com
Cynthia_sas
SAS Super FREQ
Hi:
There is some good background on arrays in this paper and, in addition, example 4 and example 5 in this paper show examples of multi-dimensional array usage:
http://support.sas.com/rnd/papers/sgf07/arrays1780.pdf

cynthia

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!

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
  • 5 replies
  • 781 views
  • 0 likes
  • 4 in conversation