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 |
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!
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.