Hello,
For example; I am trying to keep records which only have the string "street" or "corn" in them, regardless of position/upper/lowercase or anything else - how would I go about doing this?
data source;
INFILE DATALINES ;
input ID VAR & $19. CLASSIFICATION $ ;
DATALINES;
201 PepsiCo XYZ
201 111 main street XYZ
201 Charity XYZ
331 CocaCola XYZ
331 1823 unicorn street XYZ
331 Charity XYZ
331 Nike XYZ
331 123 brock avenue XYZ ;
RUN;
For instance: I tried:
DATA substrings;
SET source;
IF indexw(var,'street');
RUN;
but it creates an empty data set.
any help is much appreciated, cheers!
Sorry - don't know why it didn't copy properly before - edited it now.
Edit: Never mind, got it:
DATA string;
SET source;
WHERE varname contains 'street';
RUN;
post a sample of your data that's readable and what your required output plz
Sorry - don't know why it didn't copy properly before - edited it now.
Edit: Never mind, got it:
DATA string;
SET source;
WHERE varname contains 'street';
RUN;
@UniversitySas wrote:
Sorry - don't know why it didn't copy properly before - edited it now.
Edit: Never mind, got it:
DATA string; SET source; WHERE varname contains 'street'; RUN;
Does your data set contain a variable named VARNAME? Or are you attempting to use the VARNAME function. If the later then this won't work.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for 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.