- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Is this posible?
data have;
input id exc_1 exc_2 exc_3 inc_1 inc_2 inc_3;
cards;
1 1 0 0 0 0 1
2 1 1 0 1 0 0
3 0 0 0 1 1 1
4 0 1 1 0 1 1
;
run;
| ID | exclusion_failed | inclusion_failed |
| 1 | exc_1 | inc_3 |
| 2 | exc_1, exc_2 | inc_1 |
| 3 | inc_1, inc_2, inc_3 | |
| 4 | exc_2, exc_3 | inc_2, inc_3 |
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
data want;
set have;
length exclusion_failed $200.;
array _excl(*) exc_1-exc_3;
do i=1 to 3;
if _excl(i)=1 then exclusion_failed = catx(", ", trim(exclusion_failed), vname(_excl(i)));
end;
run;
Use VNAME() and basic array logic.
Here's a tutorial on using Arrays in SAS
https://stats.idre.ucla.edu/sas/seminars/sas-arrays/
@Nrjn7 wrote:
Is this posible?
data have;
input id exc_1 exc_2 exc_3 inc_1 inc_2 inc_3;
cards;
1 1 0 0 0 0 1
2 1 1 0 1 0 0
3 0 0 0 1 1 1
4 0 1 1 0 1 1
;
run;
ID exclusion_failed inclusion_failed 1 exc_1 inc_3 2 exc_1, exc_2 inc_1 3 inc_1, inc_2, inc_3 4 exc_2, exc_3 inc_2, inc_3
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Rules for what goes where and why.
What can you do with that (ugly) data that the first data set won't let you do?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
data want;
set have;
length exclusion_failed $200.;
array _excl(*) exc_1-exc_3;
do i=1 to 3;
if _excl(i)=1 then exclusion_failed = catx(", ", trim(exclusion_failed), vname(_excl(i)));
end;
run;
Use VNAME() and basic array logic.
Here's a tutorial on using Arrays in SAS
https://stats.idre.ucla.edu/sas/seminars/sas-arrays/
@Nrjn7 wrote:
Is this posible?
data have;
input id exc_1 exc_2 exc_3 inc_1 inc_2 inc_3;
cards;
1 1 0 0 0 0 1
2 1 1 0 1 0 0
3 0 0 0 1 1 1
4 0 1 1 0 1 1
;
run;
ID exclusion_failed inclusion_failed 1 exc_1 inc_3 2 exc_1, exc_2 inc_1 3 inc_1, inc_2, inc_3 4 exc_2, exc_3 inc_2, inc_3
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the help. This was more for the visual of the data. Appreciate and surely will look into array.