BookmarkSubscribeRSS Feed

[SAS 프로그래밍 고수 백승민] [Dummy] 가변수 생성 방법

Started ‎06-11-2020 by
Modified ‎06-12-2020 by
Views 111

DATA TEST;
INPUT age;
DATALINES;
1
2
3
4
5
;


* 방법 1;
DATA DUMMYMETHOD1;
 SET TEST;
     age1=(age=1);
     age2=(age=2);
     age3=(age=3);
     age4=(age=4);
     age5=(age=5);

PROC FREQ;
     TABLE age1 age2 age3 age4 age5;
RUN;


* 방법 2;
DATA DUMMYMETHOD2 (DROP = i);
 SET TEST;
     ARRAY A {*} age1 age2 age3 age4 age5;
     DO i = 1 TO 5;
        A(i) = (age=i);
     END;

PROC FREQ;
     TABLE age1 age2 age3 age4 age5;
RUN;


* 방법 3;
DATA DUMMYMETHOD1;
 SET TEST;
     IF age=1 then age1=1; ELSE age1 = 0;
     IF age=2 then age2=1; ELSE age2 = 0;
     IF age=3 then age3=1; ELSE age3 = 0;
     IF age=4 then age4=1; ELSE age4 = 0;
     IF age=5 then age5=1; ELSE age5 = 0;

PROC FREQ;
     TABLE age1 age2 age3 age4 age5;
RUN;

Version history
Last update:
‎06-12-2020 01:06 AM
Updated by:
Contributors

sas-innovate-white.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.

 

Early bird rate extended! Save $200 when you sign up by March 31.

Register now!

Article Labels
Article Tags