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
What happens if you use
where ASSETFLAG contains strip(TYPE);
?
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?
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 |
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.