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

I want to take a table that has the following: there are 86k rows that vary

memberID     yes         no

111                0            1

222                1            0

I want my output to be:

who              admission            count

national          yes                       0

national          no                         1

national         yes                        1

national          no                         0

The code I have is:

data chi (drop = yes no);

set final;

array _col(2) yes no;

do _n_=1to2;

who = vname (national);

admission = vname(_col(_n_));

count = _col(_n_);

output;

end;

run;

The table looks like this:

who                  national                admission          count

national                                            yes                  0

national                                             no                   1

national                                            yes                  1

national                                             no                   0

I do not want the national colunmn. Just the who column with national in it and then admission with yes and no and then the count

1 ACCEPTED SOLUTION

Accepted Solutions
Hima
Obsidian | Level 7

Code:

DATA TEMP;
INPUT memberID     yes         no;
CARDS;
111                0            1
222                1            0
;
RUN;

data chi (drop = yes no);
set TEMP;
array _col(2) yes no;
do _n_= 1,2;
who = vname (national);
admission = vname(_col(_n_));
count = _col(_n_);
output;
end;
DROP NATIONAL;
run;

PROC PRINT;
RUN;

Output:

                         member
                        Obs      ID        who       admission    count

                         1       111     national       yes         0
                         2       111     national       no          1
                         3       222     national       yes         1
                         4       222     national       no          0


View solution in original post

2 REPLIES 2
PGStats
Opal | Level 21

What is the relationship between WHO and memberID?

PG

PG
Hima
Obsidian | Level 7

Code:

DATA TEMP;
INPUT memberID     yes         no;
CARDS;
111                0            1
222                1            0
;
RUN;

data chi (drop = yes no);
set TEMP;
array _col(2) yes no;
do _n_= 1,2;
who = vname (national);
admission = vname(_col(_n_));
count = _col(_n_);
output;
end;
DROP NATIONAL;
run;

PROC PRINT;
RUN;

Output:

                         member
                        Obs      ID        who       admission    count

                         1       111     national       yes         0
                         2       111     national       no          1
                         3       222     national       yes         1
                         4       222     national       no          0


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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 1201 views
  • 0 likes
  • 3 in conversation