I have the following data:
a b c
nrename test1.nm7 0test1.nm7
nrename test2.nm7 1test2.nm7
nrename test3.nm7 0test3.nm7
What type of keep statement do I need that will allow me to keep only those rows which contain 1testi.nm7?
I plan to handle the i with a do loop but not sure how to keep a character statement.
I saw a post that gave the statement ,if sym_suffix in ('A', ' ');
When I tried
data new;
SET NEWB;
if prefix in (1, ' ');
run;
data have;
input (a b c) (:$10.);
cards;
nrename test1.nm7 0test1.nm7
nrename test2.nm7 1test2.nm7
nrename test3.nm7 0test3.nm7
;
data want;
set have;
array t b--c;
do over t;
if first(t) in (' ', '1') then f=1;
end;
if f;
drop f;
run;
array t b--c;
This means we are grouping variables starting from b and anything between b and c, including c. HTH
data have;
input (a b c) (:$10.);
cards;
nrename test1.nm7 0test1.nm7
nrename test2.nm7 1test2.nm7
nrename test3.nm7 0test3.nm7
;
data want;
set have;
array t b--c;
do over t;
if first(t) in (' ', '1') then f=1;
end;
if f;
drop f;
run;
array t b--c;
This means we are grouping variables starting from b and anything between b and c, including c. HTH
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.
Ready to level-up your skills? Choose your own adventure.