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.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.