BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jacksonan123
Lapis Lazuli | Level 10

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;
I get the following error.  What statement can I use to keep character data with the 1 prefix?
74 data new;
75 SET NEWB;
76 if prefix in (1, ' ');
ERROR: All variables in array list must be the same type, i.e., all numeric or character.
77 run;
 
 
 

 

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20
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 

View solution in original post

1 REPLY 1
novinosrin
Tourmaline | Level 20
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 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 327 views
  • 0 likes
  • 2 in conversation