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
Dataset
data one;
input Var1$ Var2 ;
datalines;
a 3
b 5
c 10
d 10
e 7
f 7
g 6
h 9
;
run;
Solution:
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;
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
Dataset
data one;
input Var1$ Var2 ;
datalines;
a 3
b 5
c 10
d 10
e 7
f 7
g 6
h 9
;
run;
Solution:
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;
No comments:
Post a Comment