Advertisement
leannemcn13

Bringing in CRF to find raw vars

Aug 11th, 2017
1,067
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SAS 0.82 KB | None | 0 0
  1. data crf4;
  2.   retain module;
  3.   set crf3;
  4.  
  5.   *add module;
  6.   if index(col1, "ADAGT:") > 0 then module = col1;
  7.   findmax=length(compress(col1,']','k'));
  8. run;
  9.  
  10. *find max number of raw var;
  11. proc sql noprint;
  12. select max(findmax)
  13. into: maxn trimmed
  14. from crf4;
  15. quit;
  16.  
  17. data varname(drop=col1 flag findmax i pos1 pos2 diff pageno check);
  18.   set crf4;
  19.   *only bring in raw var names;
  20.   where flag= "Y" ;
  21.   array varname {*} $40 variable1-variable&maxn. ;
  22.  
  23.    do i = 1 to &maxn. by 1;
  24.    check = index(col1, "]");
  25.    if check ne 0 then do;
  26.   *get varname outside of [];
  27.     pos1 = find(col1, '[') ;
  28.     pos2 = find(col1, ']');
  29.     diff = pos2-(pos1+1);
  30.     varname{i}= upcase(substr(col1, pos1+1, diff));
  31.     col1= substr(col1, pos2+1);
  32.     end;
  33.   end;
  34.  
  35.   *get pageno as numeric;
  36.   page = input(scan(pageno, 2), best.);
  37.  
  38. run;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement