BookmarkSubscribeRSS Feed

Can the following be implemented? :

A colon preceding a suffix selects with variables with the common suffix, as would select variables AC and BC in the second data step below, without error:

data have;
  AC=1;
  AD=2;
  BC=3;
  BD=4; 
  AEC=5; 
  BED=6;
data _Null_;
  set have;
  format A: z4.;
  putlog _All_;
data _Null_;
  set have;
  format :C z4.;
  putlog _All_;
run;

Colons sandwiching a search term as a use of colon wildcards, as in: 

format :E:  z5.;

 

 

Also see sasnrd.com = Drop or Keep Variables With Same Suffix

3 Comments
Rick_SAS
SAS Super FREQ

In the meantime, you might want to use regular expression parsing and the %VarListPattern macro created by Bruno Mueller and Mark Jordan. See "Use regular expressions to specify variable names in SAS."

SASKiwi
PROC Star

Perhaps a better description for this request is common prefix, rather than common suffix. While the colon wild card currently works for suffixes - text following the colon. Prefixes would refer to text preceding the colon. 

PhilC
Rhodochrosite | Level 12

Common prefixes, I define as, having the same beginning:

data _1;
  length date_begin   date_end   8
         status_begin status_end $2;
  format date_: mmddyy10. 
         status_: $status.;
run;

...and a common suffixes, not implemented, are the variables with text matching at their ends:

data _2;
  set _1;
  drop :_end; *hypothetical, for purpose of example;
run;