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!

 

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 9 replies
  • 1431 views
  • 4 likes
  • 5 in conversation