We have a SAS data Set One: Write a program to create SAS data set Two.
ONE TWO
Var1 Var2 Var1 Var2 Var3
a 3 a 3 0
b 5 b 5 0
c 10 g 6 0
d 10 e 7 1
e 7 f 7 1
f 7 h 9 0
g 6 c 10 1
h 9 d 10 1
Now prepare your Base SAS and
Advance SAS Certification Exams with Online Mock tests: http://exam.sankhyana.com
For training related info kindly mail us at info@sankhyana.com
www.sankhyana.com
ONE TWO
Var1 Var2 Var1 Var2 Var3
a 3 a 3 0
b 5 b 5 0
c 10 g 6 0
d 10 e 7 1
e 7 f 7 1
f 7 h 9 0
g 6 c 10 1
h 9 d 10 1
Now prepare your Base SAS and
Advance SAS Certification Exams with Online Mock tests: http://exam.sankhyana.com
For training related info kindly mail us at info@sankhyana.com
www.sankhyana.com
How to create Var3? What is the business definition?
ReplyDeleteThe most easy solution is
if var2=7 or var2=10
then var3=1 ;
else var3=0;
but if you want to check the duplicated values, then you need to use "by group" processing.
In this task : if var2 has duplicate values then var3 should be 1 or var3 should be 0.
Deletedata one;
ReplyDeleteinput Var1$ Var2 ;
datalines;
a 3
b 5
c 10
d 10
e 7
f 7
g 6
h 9
;
run;
proc sort data=one;
by var2;
run;
data two;
set one;
by var2;
if first.var2=last.var2 then seq=0;
else seq=1;
run;