BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
SAS_ter
Calcite | Level 5

Hi All,

I am stuck!

i have created a variable "edtime" which is in hours and minutes and is the length of stay in ED from arrival to discharge, please see code below:

data ten;

set nine;

edtime=(EDdischarge_sasdt-EDarrival_sasdt);

format edtime hhmm5.;

label edtime ='length of stay in ED from arrival to discharge';

run;

Now, I would like to calculate  the mean "edtime" By three time periods, Where two variables are (1),. How do I do this? I tried doing the following and it didn't work:

proc means data=ten q1 q3 qrange n sum std mean median clm cv min max;

var edtime;

class timeperiod;

where ltcfgroup in (1) and edtransfergroup in (1);

run;

output:

                      The MEANS Procedure

              Analysis Variable : edtime length of

              stay in ED from arrival to discharge

Time Period

    for both

   acute and

ltcf merged

       data:

(1)=time one

    (2)=time

two (3)=time    N         Lower         Upper      Quartile

       three  Obs      Quartile      Quartile         Range    N

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ

           1  148      14490.00      35490.00      21000.00  148

           2  122      15360.00      34200.00      18840.00  122

           3  158      17280.00      39840.00      22560.00  158

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ

              Analysis Variable : edtime length of

              stay in ED from arrival to discharge

  Time Period

     for both

    acute and

  ltcf merged

        data:

(1)=time one

     (2)=time

two (3)=time    N

        three  Obs           Sum        Std Dev           Mean

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ

            1  148    4740660.00       55311.91       32031.49

            2  122    3492360.00       20520.31       28625.90

            3  158    4976099.00       23854.52       31494.30

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ

          The MEANS Procedure

              Analysis Variable : edtime length of

              stay in ED from arrival to discharge

  Time Period

     for both

    acute and

  ltcf merged

        data:

(1)=time one

     (2)=time

two (3)=time    N                    Lower 95%      Upper 95%

        three  Obs        Median    CL for Mean    CL for Mean

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ

            1  148      22110.00       23046.32       41016.65

            2  122      23670.00       24947.85       32303.95

            3  158      23880.00       27745.86       35242.74

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ

              Analysis Variable : edtime length of

              stay in ED from arrival to discharge

  Time Period

     for both

    acute and

  ltcf merged

        data:

(1)=time one

     (2)=time

two (3)=time    N      Coeff of

        three  Obs     Variation        Minimum        Maximum

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ

            1  148   172.6798061        2640.00      658680.00

            2  122    71.6844075        1620.00      116940.00

            3  158    75.7423416        3300.00      174420.00

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ

Any help would be very helpful. I am not sure I can even perform a proc means with sas datetime variables. Also, is there some formatting that needs to happen?

Thanks!!!

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

The problem is that you loose your time format in the MEANS output. To keep the format, try instead:

proc means data=ten;
var edtime;
class timeperiod;
where ltcfgroup in (1) and edtransfergroup in (1);
output out=tenStats q1= q3= qrange= n= sum= std= mean= median= clm= cv= min= max= / autoname;
run;

proc print data=tenStats noobs; run;

PG

PG

View solution in original post

4 REPLIES 4
Linlin
Lapis Lazuli | Level 10

is your data sorted by timeperiod? if not try changing "by timeperiod;" to "class timeperiod;"

SAS_ter
Calcite | Level 5

i will do that, but it still doesn't give me a mean or anything of use for proc means. any other suggestions?

PGStats
Opal | Level 21

The problem is that you loose your time format in the MEANS output. To keep the format, try instead:

proc means data=ten;
var edtime;
class timeperiod;
where ltcfgroup in (1) and edtransfergroup in (1);
output out=tenStats q1= q3= qrange= n= sum= std= mean= median= clm= cv= min= max= / autoname;
run;

proc print data=tenStats noobs; run;

PG

PG
SAS_ter
Calcite | Level 5

THANK YOU SOOO MUCH!!!!

I figured it was a formatting issue but couldnt figure it out.

Thanks again!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 2445 views
  • 4 likes
  • 3 in conversation