Dear Experts,
I wrote code which looks pretty much the same in all three parts and differs just because of the different datasets. Data set names are the followings:
Retire
NoChoice
Choice
My code looks too long with 3 parts of it almost the same (actually other products(datasets) are coming in)
I feel I should use Macro but I have no idea how to start as I never did it before (although I read help on- line)
The following is code for the first part-retire:
data RetireDist;
set Retire;
gls=put(gl, $1.);
SuS=put(Su, $1.);
UrS=put(Ur, $1.);
hS=put(h, $1.);
Es=put(E, $1.);
fs=put(f, $1.);
if gl='1' THEN glS='Y';
else glS='N';
if su='1' OR
su='2' THEN suS='Y';
else suS='N';
if Ur='1' THEN UrS='Y';
else UrS='N';
if h='2' OR
h='3' THEN hS='Y';
else hS='N';
IF E='2' THEN ES='Y';
else ES='N';
if f='1' OR
f='2' THEN footExamS='Y';
else fS='N';
Bmem1 = substr(glS,1,1);
Bmem2 = substr(suS,1,1);
Bmem3 = substr(UrS,1,1);
Bmem4 = substr(hS,1,1);
Bmem5 = substr(ES,1,1);
Bmem6 = substr(fS,1,1);
/* Count # of Knowledge Questions for each patient out of the 6 of interest */
array Bcalc [6] $Bmem1-Bmem6;
Bcount=0;
do i=1 to 6;
if Bcalc(i) EQ 'Y' then Bcount=Bcount+1;
end;
drop i;
RUN;
proc freq data=RetireDist;
tables glS suS UrS hS ES fS;
title "Distribution Frequency of Yes answers for Specific questions for Retire";
run;
proc freq data= RetireDist;
tables Bcount;
title "Frequency of Count of Yes answers in the Retire";
run;
Data data NochoiceDist;
set NoChoice;
.
.
.
same code
run;
Data data choiceDist;
set Choice;
.
.
.
same code
run;
Could you give me a hand?
Thank you for your time and consideration!
Rina
I wrote code which looks pretty much the same in all three parts and differs just because of the different datasets. Data set names are the followings:
Retire
NoChoice
Choice
My code looks too long with 3 parts of it almost the same (actually other products(datasets) are coming in)
I feel I should use Macro but I have no idea how to start as I never did it before (although I read help on- line)
The following is code for the first part-retire:
data RetireDist;
set Retire;
gls=put(gl, $1.);
SuS=put(Su, $1.);
UrS=put(Ur, $1.);
hS=put(h, $1.);
Es=put(E, $1.);
fs=put(f, $1.);
if gl='1' THEN glS='Y';
else glS='N';
if su='1' OR
su='2' THEN suS='Y';
else suS='N';
if Ur='1' THEN UrS='Y';
else UrS='N';
if h='2' OR
h='3' THEN hS='Y';
else hS='N';
IF E='2' THEN ES='Y';
else ES='N';
if f='1' OR
f='2' THEN footExamS='Y';
else fS='N';
Bmem1 = substr(glS,1,1);
Bmem2 = substr(suS,1,1);
Bmem3 = substr(UrS,1,1);
Bmem4 = substr(hS,1,1);
Bmem5 = substr(ES,1,1);
Bmem6 = substr(fS,1,1);
/* Count # of Knowledge Questions for each patient out of the 6 of interest */
array Bcalc [6] $Bmem1-Bmem6;
Bcount=0;
do i=1 to 6;
if Bcalc(i) EQ 'Y' then Bcount=Bcount+1;
end;
drop i;
RUN;
proc freq data=RetireDist;
tables glS suS UrS hS ES fS;
title "Distribution Frequency of Yes answers for Specific questions for Retire";
run;
proc freq data= RetireDist;
tables Bcount;
title "Frequency of Count of Yes answers in the Retire";
run;
Data data NochoiceDist;
set NoChoice;
.
.
.
same code
run;
Data data choiceDist;
set Choice;
.
.
.
same code
run;
Could you give me a hand?
Thank you for your time and consideration!
Rina