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

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 3 replies
  • 585 views
  • 2 likes
  • 2 in conversation