BookmarkSubscribeRSS Feed
sateh
Fluorite | Level 6


I have a table with the following structure

sateh_0-1669653988511.png


I need to store in a new column the names of columns where in their records is 1, here is an example of what I want to do, the names of the columns can be separated with , when I store it in that new variable called list as seen in the image highlighted in yellow

sateh_1-1669654125050.png

 

2 REPLIES 2
PaigeMiller
Diamond | Level 26

This is a very difficult arrangement of data to work with, and should be avoided in most cases.

 

What would you do with this new variable once you have it?

--
Paige Miller
PeterClemmensen
Tourmaline | Level 20

I do not recommend this.

 

data want;
   set have;
   array r ACCESO_ADMIN_JUSTICIA -- SEGURIDAD_SOCIAL;
   length listado $200;
   
   do over r;
      if r = 1 then listado = catx(',', listado, vname(r));
   end;
   
run;

Ready to join fellow brilliant minds for the SAS Hackathon?

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!
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
  • 2 replies
  • 493 views
  • 0 likes
  • 3 in conversation