There are several ways to do this in SAS. I've listed a few in my code below. My personal favorite is to remove my 'code' list into a custom format (option 3 below) that way it is in one spot in case I ever need to update it.
/*Assuming code is numeric, otherwise encapsulate each code in '' (i.e. '59400' vs. 59400)*/
data have;
input code;
datalines;
1
59515
59400
5
59410
59510
;
run;
data desired_output;
input code;
datalines;
59515
59400
59410
59510
;
run;
/*Option 1*/
data opt1;
set have;
if code in (59400 59410 59510 59515); /*equivalent to: if code in (59400 59410 59510 59515) then output; */
run;
/*Option 2: place in set (where=) -- only reads in observations that match your criteria*/
data opt2;
set have(where=(code in (59400 59410 59510 59515)));
run;
/*Option 3: remove logic from data step and place in custom format*/
proc format;
value mycodes
59400, 59410, 59510, 59515="1"
other="0"
;
run;
data opt3a;
set have;
if put(code,mycodes.); /*equivalent to: if put(code,mycodes.)="1" then output; */
run;
data opt3b;
set have(where=(put(code,mycodes.)="1"));
run;
/*Option 4: remove logic from data step and place in macro variable*/
%let mycodes = (59400 59410 59510 59515);
data opt4a;
set have;
if code in &mycodes; /*equivalent to: if put(code,mycodes.)=1 then output; */
run;
data opt4b;
set have(where=(code in &mycodes));
run;
/*Checking that results=desired_results*/
proc compare base=desired_output compare=opt1;
proc compare base=desired_output compare=opt2;
proc compare base=desired_output compare=opt3a;
proc compare base=desired_output compare=opt3b;
proc compare base=desired_output compare=opt4a;
proc compare base=desired_output compare=opt4b;
run;
-unison