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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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