@Reeza I tried that, it's similar to what @ballardw first posted. You have N=8. N should be =4 because I have 4 patients. In proc ttest for example there is a way to pair two columns. For a example using your tranposed data set 'wide'. Is there something like that in proc means or any other procedure to calculate the mean, min, max etc?
proc ttest data= wide plots=none;
paired visit_1*visit_2;
ods output ttests=ttest_1;
ods output Statistics=Stat_1;
run;
@PaigeMiller @Reeza @ballardw : I finally solved it this way
proc sql;
create table test1 as select patid as patid1, visit as visit1 , var as var1 from test where visit=1;
create table test2 as select patid as patid2, visit as visit2 , var as var2 from test where visit=2;
create table test3 as select a.*, b.* from test1 as a right join test2 as b on a.patid1=b.patid2;
quit;
proc means data=test3 n mean std min max nmiss;
var var1;
run;
and as result :
That is what I wanted, thanks for the help
or just
proc sql;
select n(a.var) as n, mean(a.var) as mean, std(a.var) as std /* insert other stats */
from work.test a
join work.test b on a.patid = b.patid and a.visit = 1 and b.visit = 2
;
quit;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.