BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
GPatel
Pyrite | Level 9
  RAW_DATA              
Obs Flag_A Flag_B Flag_C Flag_D Flag_E Flag_F Flag_G N
1 No             1
2 Yes             2
3   No           3
4     No         4
5     Yes         5
6       No       6
7       Yes       7
8         No     8
9         Yes     9
10           No   10
11           Yes   11
12             No 12
13             Yes 13
                 
  RRQUIRED:              
  Flag_A No 1          
  Flag_A Yes 2          
  Flag_B No 3          
  Flag_B Yes 0          
  Flag_c No 4          
  Flag_c Yes 5          
  Flag_d No 6          
  Flag_D Yes 7          
  Flag_E No 8          
  Flag_E Yes 9          
  Flag_F No 10          
  Flag_F Yes 11          
  Flag_G No 12          
  Flag_G Yes 13          
1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

Arrays would come in handy, especially if you actually have more than six variables:

 

data want;

set have;

array flags {6} Flag_A Flag_B Flag_C Flag_D Flag_E Flag_F;

do _n_=1 to 6;

   if flags{_n_} > ' ' then do;

   FlagVar = vname(flags{_n_});

   Flag = flags{_n_};

end;

keep FLagVar Flag N;

run;

View solution in original post

9 REPLIES 9
ballardw
Super User

Is this for a report or a data set?

GPatel
Pyrite | Level 9

This is for data set and then Proc GChart.

Astounding
PROC Star

Arrays would come in handy, especially if you actually have more than six variables:

 

data want;

set have;

array flags {6} Flag_A Flag_B Flag_C Flag_D Flag_E Flag_F;

do _n_=1 to 6;

   if flags{_n_} > ' ' then do;

   FlagVar = vname(flags{_n_});

   Flag = flags{_n_};

end;

keep FLagVar Flag N;

run;

GPatel
Pyrite | Level 9

Our community "Astounding" user provided excellent solutions. 

GPatel
Pyrite | Level 9

Our community "Astounding" user provided excellent and timely solutions. 

Reeza
Super User

@GPatel wrote:

Our community "Astounding" user provided excellent and timely solutions. 


Please mark that solution as the correct answer 🙂

Reeza
Super User

You should have marked @Astounding solution as correct, not mine! 

Maybe @ShelleySessoms can fix this? 

 

Thanks

ShelleySessoms
Community Manager

All fixed! Thanks for alerting us to the incorrect mark, @Reeza. We definitely want to acknowledge the correct answer!

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 9 replies
  • 2110 views
  • 4 likes
  • 5 in conversation