BookmarkSubscribeRSS Feed
Ranjeeta
Pyrite | Level 9

PROC TABULATE DATA=evt_qbp;
WHERE EX_LT90FU=0 AND EX_HISTORY~=1;
FORMAT FLAG_POSTDX YESNO_FMT.;
CLASS FLAG_POSTDX;
CLASS FACILITY_NO / ORDER=FREQ;
VAR HOMETIME;
TABLES FACILITY_NO ALL,
(ALL='Includes In-hospital Strokes' FLAG_POSTDX)*HOMETIME
*(N='Included Cases' MEDIAN );
TITLE1 "EVT Indicator 6: Home Time within 90-Days Following EVT, FY2017/2018";
TITLE2 "Including Deaths within 90 Days Following EVT";
RUN;

 

Hello 

Can someone advise if the code above will correctly calculate the toal cases and the median for only the variable Hometime 

Also what happens if I include ne additional in the var statement 

will the total and median be calculated for both variables in the var statement

3 REPLIES 3
Kurt_Bremser
Super User

@Ranjeeta wrote:

PROC TABULATE DATA=evt_qbp;
WHERE EX_LT90FU=0 AND EX_HISTORY~=1;
FORMAT FLAG_POSTDX YESNO_FMT.;
CLASS FLAG_POSTDX;
CLASS FACILITY_NO / ORDER=FREQ;
VAR HOMETIME;
TABLES FACILITY_NO ALL,
(ALL='Includes In-hospital Strokes' FLAG_POSTDX)*HOMETIME
*(N='Included Cases' MEDIAN );
TITLE1 "EVT Indicator 6: Home Time within 90-Days Following EVT, FY2017/2018";
TITLE2 "Including Deaths within 90 Days Following EVT";
RUN;

 

Hello 

Can someone advise if the code above will correctly calculate the toal cases and the median for only the variable Hometime 

Also what happens if I include ne additional in the var statement 

will the total and median be calculated for both variables in the var statement


Maxim 4: try it.

ballardw
Super User

Proc Tabulate will only calculate statistics other than the "N"  related statistics (N pctn colpctn rowpctn) for variables declared on a VAR statement.  "Correctly" depends on what you intend, especially when you say" the total cases "; If you want an overall including both the ROW and the COLUMN values then you want have an ALL on the row dimension as well.

Your code will create one column for each level of FLAG_POSTDX and all combined for each level of the row variable FACILITY_NO ALL.

 

If weren't aware, the Proc Tabulate will by default remove any record that has a missing value for any of the CLASS variables. So that can also impact "correctly".

 

Generally to request the same statistics for multiple variables place the variables within parentheses and the statistics in another set of parentheses with the * between them. See an example:

proc tabulate data=sashelp.class;
   class sex;
   var height weight;
   table sex,
         (height weight) *(n max min median)
   ;
run;

 if they are not inside () then the variables are treated a separate requests and could request the same or different statistics

 

proc tabulate data=sashelp.class;
   class sex;
   var height weight;
   table sex,
         height  *(n max min median)
         weight * (mean std)
   ;
run;
PGStats
Opal | Level 21

What problem (doubt) did you run into with the stated syntax?

 

What happens when you include another variable in the VAR statement depends on where you include this new variable in the TABLES statement.

 

If you say

 

VAR HOMETIME OtherVar;
TABLES FACILITY_NO ALL,
(ALL='Includes In-hospital Strokes' FLAG_POSTDX)*(HOMETIME Othervar)
*(N='Included Cases' MEDIAN );

 

you will get parallel columns for both VAR variables in each FLAG_POSTDX category and for ALL.

 

PG

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

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
  • 3 replies
  • 660 views
  • 3 likes
  • 4 in conversation