BookmarkSubscribeRSS Feed
imdickson
Quartz | Level 8

Hi everyone, i tried to filter some data that i want within a dataset. Lets have a look at the same data:

 

Table A

pmu  ssu   assetflag   type

aa     bb    bb cc dd    cc

11     22    22 33 44    44

xx     yy     yy zz pp    pp

ee     ff      ff gg hh     ee

 

I want to filter out data that "type" has in "assetflag".

 

My SQL Statement:

proc sql;
select * from a
where
assetflag contains type;
quit;

 

However, i do not see the result at all. 0 records.

What is wrong? BTW, i remember seeing someone posted that CONTAINS to follow with &&&.....however, i think that only applies to macro variable. Correct me if im wrong

3 REPLIES 3
ChrisNZ
Tourmaline | Level 20

What happens if you use 

where ASSETFLAG contains strip(TYPE);

 ?

imdickson
Quartz | Level 8

It seems to me the filter with that statement will not have any effect at all. I still get the same result set(FULL) if i use that.

 

DO i need to wrap both side of the variable with double quote?

ChrisNZ
Tourmaline | Level 20

 I still get the same result set(FULL) if i use that.

No you don't.

data HAVE;
 input (PMU  SSU   ASSETFLAG   TYPE) (& $);
 cards;
aa     bb    bb cc dd    cc
11     22    22 33 44    44
xx     yy    yy zz pp    pp
ee     ff     ff gg hh   ee
run;
proc sql;
 select * from HAVE where ASSETFLAG contains strip(TYPE);
quit

PMU SSU ASSETFLAG TYPE
aa bb bb cc dd cc
11 22 22 33 44 44
xx yy yy zz pp pp

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1043 views
  • 2 likes
  • 2 in conversation