I have this data:
data have;
input test $25. ;
cards;
0 | 0 | 0 | 0 | 0
0 | 1 | 0
1
2
0 | 24 | 0
0 | 0 | 0 | 23
0 | 0| 23 | 24 | 1
0 | 0
0 | 0 | 1
0
27
;
run;
And I want to have this:
data want;
input test $22. want 4. ;
cards;
0 | 0 | 0 | 0 | 0 1
0 | 1 | 0 0
1 0
2 0
0 | 24 | 0 0
0 | 0 | 0 | 23 0
0 | 0 | 23 | 24 | 1 0
0 | 0 1
0 | 0 | 1 0
0 1
27 0
;
run;
The values were separated by " | " and I need to find what obs that have ONLY zero. I tried to use a couple of procedures but NONE seems working properly. If anyone can help I would highly appreciate!
Best,
Le
data have;
input test $25. ;
cards;
0 | 0 | 0 | 0 | 0
0 | 1 | 0
1
2
0 | 24 | 0
0 | 0 | 0 | 23
0 | 0| 23 | 24 | 1
0 | 0
0 | 0 | 1
0
27
;
run;
proc print;
run;
data want;
set have;
want=^lengthn(compress(test,"0|","s"));
run;
proc print;
run;
data have;
input test $25. ;
cards;
0 | 0 | 0 | 0 | 0
0 | 1 | 0
1
2
0 | 24 | 0
0 | 0 | 0 | 23
0 | 0| 23 | 24 | 1
0 | 0
0 | 0 | 1
0
27
;
run;
proc print;
run;
data want;
set have;
want=^lengthn(compress(test,"0|","s"));
run;
proc print;
run;
For having some fun.
data have;
input test $25. ;
cards;
0 | 0 | 0 | 0 | 0
0 | 1 | 0
1
2
0 | 24 | 0
0 | 0 | 0 | 23
0 | 0| 23 | 24 | 1
0 | 0
0 | 0 | 1
0
27
;
run;
data want;
set have;
want=verify(test,"0| ")=0;
run;
proc print;
run;
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: