BookmarkSubscribeRSS Feed
UrvishShah
Fluorite | Level 6

Hi

Suppose you have to at least one categories out of 10
category name
X1multiple choice may be possible
X2
X3
X4
X5
X6
X7
X8
X9
X10
so data will be resprented as below
NameX1X2X3X4X5X6X7X8X9X10total cat
A11110000004
B00100001103
C11100001105
D11000001104
E01000000102
F00000001001
G00100000012
H10000000012
I01100000013
J11000000002
then output should be come this way
name of cater
X1X2X3X40
X3X8X900
X1X2X3X8X9
X1X2X8X90
X2X9000
X80000
X30000
X1X10000
X2X3X1000
X1X2000


Regards

1 REPLY 1
art297
Opal | Level 21

Here is one way:

data have;

  input Name $ X1-X10 total_cat;

  cards;

A          1          1          1          1          0          0          0          0          0          0          4

B          0          0          1          0          0          0          0          1          1          0          3

C          1          1          1          0          0          0          0          1          1          0          5

D          1          1          0          0          0          0          0          1          1          0          4

E          0          1          0          0          0          0          0          0          1          0          2

F          0          0          0          0          0          0          0          1          0          0          1

G          0          0          1          0          0          0          0          0          0          1          2

H          1          0          0          0          0          0          0          0          0          1          2

I          0          1          1          0          0          0          0          0          0          1          3

J          1          1          0          0          0          0          0          0          0          0          2

;

proc sql noprint;

  select distinct max(total_cat)

    into :maxcat

      from have

  ;

quit;

data want (keep=name used:);

  set have;

  array selected(*) x1-x10;

  array used(&maxcat.) $2.;

  j=0;

  do i=1 to &maxcat.;

    used(i)='0';

  end;

  do i=1 to dim(selected);

    if selected(i) eq 1 then do;

      j+1;

      used(j)=vname(selected(i));

    end;

  end;

run;

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 1 reply
  • 600 views
  • 0 likes
  • 2 in conversation