From: Shaik Hymad on
hi to All,

I have data like

side_t PATID VRD sampno PVAL mhdt side
LEFT 01S0018 0 129 0 -0.493 1
LEFT 01S0018 1 370 1 1.975 1
LEFT 01S0019 0 137 1 6.44 1
RIGHT 01S0019 0 144 0 2
RIGHT 01S0024 0 183 1 1.367 2
LEFT 01S0024 1 402 0 5.53 1
RIGHT 01S0024 1 405 1 19.817 2
LEFT 01S0028 0 211 1 1.342 1
LEFT 01S0028 0 212 1 1.032 1
LEFT 01S0028 1 436 1 1.14 1
RIGHT 01S0028 1 437 0 2.876 2
RIGHT 01S0028 1 440 1 4.019 2

I need output like

if pval=1 then only I have to calculate sum of mhdt based on left side
samples and vorder wise



if pval=0 its not include in sum and count variable

can you please check this code


data ncontac2(drop=sampleno);
set ncontac1;
retain mhdent c;
by patid vorder side;
if pval ne 0 then do;
if first.side then do;mhdent=.;c=.;end;
if mhdt ne . then do;
mhdent=sum(mhdent, mhdt);
c+1;
end;
end;
else do;
mhdent=mhdt;
end;
if last.side ;
run;

as per this code,im getting count for subject 01S0028 right side count is
3
but i want only 1. can you please check and let me know

Thanks,
Hymad