Skip to content

Instantly share code, notes, and snippets.

@statgeek
Last active September 4, 2018 17:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save statgeek/f052b5223fecca066b1f to your computer and use it in GitHub Desktop.
Save statgeek/f052b5223fecca066b1f to your computer and use it in GitHub Desktop.
Temporary Arrays in SAS - loaded from dataset
/*Sample of lookup using Temporary Arrays*/
*Generate sample data;
data scores;
input Name $ Test_1 Test_2 Test_3;
datalines;
Bill 187 97 103
Carlos 156 76 74
Monique 99 102 129
;
*generate lookup values;
data M;
do k=10,20,30,40,50,60,70,100,120,130;
output;
end;
run;
data want;
*loads data set M into temporary array M;
array M(10) _temporary_;
if _n_=1 then do j=1 to 10;
set M;
M(j)=k;
end;
*main data set to work with;
set scores;
rank=0;
*assigns rank based on groups above;
do i=1 to 10 while (rank=0);
if m(i)> test_3 then rank=i-1;
end;
drop i j;
run;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment