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.
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 lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.