Sarah
Sarah

Reputation: 103

Creating two different instances of the same variable in SAS

I need to sort one variable, class, to create a new variable, num. For the missing class, num=1. For the "EXE" class, num needs to equal 2 and 1. I need to have two instances of the same EXE row and one needs to be num=1 while the other needs to be num=2.

This is the data I have because I don't know how to make EXE twice and the apply it to 1 and 2.

data work.ALL ;
        set work.test1 work.test2 work.test3;
    if class="EXE" then num=2;
    else if class=" " then num=1;
run;

Upvotes: 0

Views: 62

Answers (2)

Jonas
Jonas

Reputation: 321

If i understand your question correct then this should do the trick.

data work.ALL ;
        set work.test1 work.test2 work.test3;
    if class="EXE" then do;
    num=2;output;
    num=1;output;
    end;
    else if class=" " then num=1;
output;    
run;

Upvotes: 1

kittymad
kittymad

Reputation: 93

I think this should work:

data work.ALL ;
set work.test1 work.test2 work.test3;
if class=" " then do;
num=1;
output;
end;
else if class="EXE" then do;
num = 1; output;
num = 2; output;
end;
run;

Upvotes: 1

Related Questions