turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- General Programming
- /
- create composite variable

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-20-2016 04:27 PM

I have a dataset related to kidney transplants and each donor has a donor id and both the left and right kidneys are tied to that donor id.

I need to create a binary variable called 'discard' (0=no, 1=yes) that is a composite of left and right kidney dispositions.

Currently I have the variables:

donor_id

r_disp (5=discard, 6=transplant)

l_disp (5=discard, 6=transplant)

How do I create a variable called "discard" that will be a composite indicator of r_disp and l_disp so that I can investigate the odds of discard overall?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-20-2016 04:34 PM

If r_disp and l_disp are on the same record in a data step:

(flag if either are discarded)

discard = (r_disp=5 or l_disp=5);

(flag if BOTH are discarded)

discard = (r_disp=5 and l_disp=5);

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-20-2016 04:36 PM

Could you give example of the data you have ?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-20-2016 04:55 PM

A single observation will show data for the following variables (among others):

Donor_id

r_disp (fate of right kidney)

L_disp (fate of left kidney)

Kdri (measure of kidney quality)

Donor_id is the index variable.

I want to run a proc logistic to investigate the odds of discard but I only have discard data by left and right. So I need to combine them someone into one discard variable for analysis.

Donor_id

r_disp (fate of right kidney)

L_disp (fate of left kidney)

Kdri (measure of kidney quality)

Donor_id is the index variable.

I want to run a proc logistic to investigate the odds of discard but I only have discard data by left and right. So I need to combine them someone into one discard variable for analysis.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-20-2016 04:58 PM

Yes, what your logic ?

if both of them are diecard then discard =1

or

if any one of them is dicard then discard=1

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-20-2016 05:01 PM

data have ;
input ID r_disp l_disp;
cards;
111 5 5
112 6 6
113 5 6
114 6 6
;
run;
data want ;
set have;
if r_disp=5 and l_disp=5 then discard=1;
else discard =0;
run;

That is example.

If you want discard to equal 1 if the right **or** the left is discard then change the "**and**" to "**or**" in the IF condition.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-21-2016 10:55 AM

The logic of discard or not isn't clear but something like this seems right:

data have;

input ID$ r_disp$ l_disp$;

cards;

1 5 5

2 5 6

3 6 5

4 6 6

;run;

data want;

set have;

if r_disp = '6' or l_disp = '6' then Discard = '0';

else discard = '1';

run;