BookmarkSubscribeRSS Feed
Anita_n
Pyrite | Level 9

@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;

Reeza
Super User
Only the first proc means has N=8 the remaining have other N's that reflect different summaries.
All of the proc means are also saving the output to a data set.
Please review the code in detail.
Anita_n
Pyrite | Level 9

@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 :

 

Anita_n_0-1639740776977.png

That is what I wanted, thanks for the help 

 

andreas_lds
Jade | Level 19

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;
Reeza
Super User
Which is identical to the last proc means in my example.

Catch up on SAS Innovate 2026

Dive into keynotes, announcements and breakthroughs on demand.

Explore Now →
How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 19 replies
  • 4166 views
  • 2 likes
  • 5 in conversation