BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Nrjn7
Fluorite | Level 6

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;

 

IDexclusion_failedinclusion_failed
1exc_1inc_3
2exc_1, exc_2inc_1
3 inc_1, inc_2, inc_3
4exc_2, exc_3inc_2, inc_3

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
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

 

 


 

View solution in original post

3 REPLIES 3
ballardw
Super User

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?

Reeza
Super User
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

 

 


 

Nrjn7
Fluorite | Level 6

Thanks for the help. This was more for the visual of the data. Appreciate and surely will look into array.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 886 views
  • 0 likes
  • 3 in conversation