BookmarkSubscribeRSS Feed
kisumsam
Quartz | Level 8

Hello, I'm reading the advanced study guide and I got a question with regards to using multiple array to look up values. Below are the sample program:

 

data work.lookup1;
 array Targets{1997:1999,12} _temporary_;
 if _n_=1 then do i= 1 to 3;
 set sasuser.ctargets;
 array mnth{*} Jan--Dec;
 do j=1 to dim(mnth);
 targets{year,j}=mnth{j};
 end;
 end;
 set sasuser.monthsum(keep=salemon revcargo monthno);
 year=input(substr(salemon,4),4.);
 Ctarget=targets{year,monthno};
 format ctarget dollar15.2;
run;

Just curious, what's the advantage of using array over simply merging the data sets? It seems to be this technique isn't very useful. 

 

Do people actually use this technique in practice?

 

 

1 REPLY 1
Reeza
Super User

Yes it is used, notice this is a temporary array. 

 

A temporary array is reading the dataset once and loading it into memory. Loading it into memory means the lookup can be faster than a standard merge. Merges require you sort both data sets, there's no sort required here. 

 

 

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