BookmarkSubscribeRSS Feed
kwu
SAS Employee kwu
SAS Employee
I find this in the sas doc about initialing an array with a sequential integers.

It just says:

You can also use a shorthand notation for specifying a range of sequential integers. The increment is always +1.

but no example, I wonder if anyone would tell me what is it and how to do it?
thank you
1 REPLY 1
ArtC
Rhodochrosite | Level 12
The sytax is the first and last values separated by a colon (you gotta love the colon it does so much for us). Here the array x will range from 10 to 15.
[pre]array x{6} _temporary_ (10:15);[/pre]

The following step augments this definition by passing through a list of values twice.
[pre]data silly;
array x{10} _temporary_ (2*1:5);
do i = 1 to dim(x);
y= x{i};
put i= y= ;
end;
run;
[/pre]

SAS Innovate 2025: Register Today!

 

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1235 views
  • 0 likes
  • 2 in conversation