## Programming the statistical procedures from SAS

Regular Contributor
Posts: 180

Hi there,

I am wondering abouthow to calculate the unadjusted rate in SAS. I want it in form of   ##/1000 (number over 1000)

What i have done is , is used the percentages that i got from proc freq and just multiplied it by 1000. But i am not sure if that is really a right way to do it.

I am told that there is way in SAS to calculate the unadjusted rate.

Does anyone know how to do it?

Any help will be highly appreciated..

Thanks,

Ashwini

PROC Star
Posts: 7,650

I think you have to be a bit more explicit as to what you are looking to achieve.

Regular Contributor
Posts: 180

I am attaching the tables below..they are the  chi-square output . I have multiplied the the underlined and bold numbers (which are percentages) with 1000 to get a unadjusted rate per 1000. I intend to create a grapth for females and males using these unadjusted rates.

Is it a right way to do it? I have never calculated the unadjusted rates before.

Is there any other way or method or SAS code to  obtain the unadjusted rate?

Hope i am making sense,

Thanks,
Ashwini

Percent          ‚

Row Pct          ‚

Col Pct          ‚ 0: Did ‚ 1: Died‚  Total

‚not die ‚ in hosp‚

‚in hospi‚ital    ‚

‚tal     ‚        ‚

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ

0: Male         ‚6182.83 ‚ 724.06 ‚6906.89

‚  51.00 ‚   5.97 ‚  56.97

‚  89.52 ‚  10.48

‚  56.98 ‚  56.91 ‚

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ

1: Female       ‚4667.86 ‚548.134 ‚   5216

‚  38.50 ‚   4.52 ‚  43.03

‚  89.49 ‚  10.51

‚  43.02 ‚  43.09 ‚

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ

Total             10850.7  1272.19  12122.9

89.51    10.49   100.00

Percent          ‚

Row Pct          ‚

Col Pct          ‚ 0: Did ‚ 1: Died‚  Total

‚not die ‚ in hosp‚

‚in hospi‚ital    ‚

‚tal     ‚        ‚

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ

0: Male         ‚70899.8 ‚2252.25 ‚73152.1

‚  69.33 ‚   2.20 ‚  71.53

‚  96.92 ‚  3.08

‚  72.17 ‚  55.93 ‚

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ

1: Female       ‚27338.7 ‚ 1774.9 ‚29113.6

‚  26.73 ‚   1.74 ‚  28.47

‚  93.90 ‚  6.10

‚  27.83 ‚  44.07 ‚

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ

Total             98238.6  4027.15   102266

96.06     3.94   100.00

Frequency        ‚

Percent          ‚

Row Pct          ‚

Col Pct          ‚ 0: Did ‚ 1: Died‚  Total

‚not die ‚ in hosp‚

‚in hospi‚ital    ‚

‚tal     ‚        ‚

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ

0: Male         ‚8262.34 ‚430.063 ‚ 8692.4

‚  71.80 ‚   3.74 ‚  75.54

‚  95.05 ‚   4.95

‚  75.72 ‚  72.26 ‚

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ

1: Female       ‚2650.08 ‚165.079 ‚2815.16

‚  23.03 ‚   1.43 ‚  24.46

‚  94.14 ‚   5.86

‚  24.28 ‚  27.74 ‚

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ

Total             10912.4  595.142  11507.6

94.83     5.17   100.00

Posts: 2,116

In general, an unadjusted rate is just a proportion.  If you want to express it as percent, divide by 100.  Dividing by 1000 is what is done in the US to get a baseball batting average (Someone who is batting 260 is getting a hit 26% of the time).

There are a few other kinds of "unadjusted rates" that might also under consideration, such as the speed of a car.  You still get it by dividing two numbers (distance traveled/time).

Doc Muhlbaier

Duke

Regular Contributor
Posts: 180

I am attaching the tables below..they are the  chi-square output . I have multiplied the the underlined and bold numbers (which are percentages) with 1000 to get a unadjusted rate per 1000. I intend to create a grapth for females and males using these unadjusted rates.

Is it a right way to do it? I have never calculated the unadjusted rates before.

Is there any other way or method or SAS code to  obtain the unadjusted rate?

Hope i am making sense,

Thanks,
Ashwini

Percent          ‚

Row Pct          ‚

Col Pct          ‚ 0: Did ‚ 1: Died‚  Total

‚not die ‚ in hosp‚

‚in hospi‚ital    ‚

‚tal     ‚        ‚

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ

0: Male         ‚6182.83 ‚ 724.06 ‚6906.89

‚  51.00 ‚   5.97 ‚  56.97

‚  89.52 ‚  10.48

‚  56.98 ‚  56.91 ‚

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ

1: Female       ‚4667.86 ‚548.134 ‚   5216

‚  38.50 ‚   4.52 ‚  43.03

‚  89.49 ‚  10.51

‚  43.02 ‚  43.09 ‚

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ

Total             10850.7  1272.19  12122.9

89.51    10.49   100.00

Percent          ‚

Row Pct          ‚

Col Pct          ‚ 0: Did ‚ 1: Died‚  Total

‚not die ‚ in hosp‚

‚in hospi‚ital    ‚

‚tal     ‚        ‚

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ

0: Male         ‚70899.8 ‚2252.25 ‚73152.1

‚  69.33 ‚   2.20 ‚  71.53

‚  96.92 ‚  3.08

‚  72.17 ‚  55.93 ‚

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ

1: Female       ‚27338.7 ‚ 1774.9 ‚29113.6

‚  26.73 ‚   1.74 ‚  28.47

‚  93.90 ‚  6.10

‚  27.83 ‚  44.07 ‚

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ

Total             98238.6  4027.15   102266

96.06     3.94   100.00

Frequency        ‚

Percent          ‚

Row Pct          ‚

Col Pct          ‚ 0: Did ‚ 1: Died‚  Total

‚not die ‚ in hosp‚

‚in hospi‚ital    ‚

‚tal     ‚        ‚

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ

0: Male         ‚8262.34 ‚430.063 ‚ 8692.4

‚  71.80 ‚   3.74 ‚  75.54

‚  95.05 ‚   4.95

‚  75.72 ‚  72.26 ‚

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ

1: Female       ‚2650.08 ‚165.079 ‚2815.16

‚  23.03 ‚   1.43 ‚  24.46

‚  94.14 ‚   5.86

‚  24.28 ‚  27.74 ‚

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ

Total             10912.4  595.142  11507.6

94.83     5.17   100.00

Posts: 5,048

You could simply use a SQL query. Assuming that the three tables reflect 3 values of variable myByVar you could use something like :

proc sql;

create table rates1000 as

select myByVar, sex, 1000*sum(died)/count(died)

from myData

group by myByVar, sex;

PG

PG
Regular Contributor
Posts: 180

I got lot of warnings here.

Now that i have never run a SQL query before, i am probably not doing it correctly,

The nae of the variable is Gender and there are 2 levels. 1=female and 0= malem what do i plug in as "sex" one of the 2 levels?

so here is how the SQl query looks like?

proc sql;

create table rates1000 as

select gender, sex, 1000*sum(died)/count(died)

from library.nismicathcabg4;group by gender, sex;

Regular Contributor
Posts: 180

Sorry, i am not able to run the SQL query..

would you mind heloping me with the SQL syntax?

Posts: 5,048

I assume your variables are as follows (replace the names in the query with your own variable names) :

myByVar : whatever separates the three tables that you presented earlier

gender : separates the sexes

died : 0 or 1 indicates if died in hospital

with this information, the query should be :

proc sql;

create table rates1000 as

select myByVar, gender, 1000*sum(died)/count(died) as rate1000

from library.nismicathcabg4

group by myByVar, gender;

PG

PG
Regular Contributor
Posts: 180

thanks again, but I amstill not getting it.

what output should i exactly expect?

Does the output show in the ouput window or it created as a table?

This is how my syntax looks like: i am doing it separatly for the above 3 tables..using PCIONLY, diagcathonly, cabgonly. does this look right?

proc sql;

create table rates1000 as

select pcionly, gender, 1000*sum(died)/count(died) as rate1000

from library.nismicathcabg4;

group by pcionly, gender;

quit;

Do you think this sql code me would give me a different output that what i get by multiplying the numbers(underlined and bold in the tables i posted earlier) by 1000.

Posts: 5,048

First, I need to know what are PCIONLY, diagcathonly and cabgonly? Are they binary variables (value 0 or 1)?

The output is in dataset WORK.rates1000

Use

proc print data=rates1000; run;

to see it.

PG

PG
Regular Contributor
Posts: 180

PCIONLY, diagcathonly and cabgonly are binary variables with values 0 and 1.

I looked at the output and i gave me a same value 53.8 for (82000 records) , but the log window shows warnings: such as

Statement is not valid or it is used out of proper order.   I am not sure about this, I guess there is till some error in the syntax

I also need to weight my cases..

In SAS I use weight discwt statement  (discwt is the weighting variable)

I donot know how to do this in sql query

Posts: 5,048

Ok. Now the problem is getting better defined... Try :

proc sql;

create table rates1000 as

select pcionly, diagcathonly, cabgonly, gender,

1000*sum(died*discwt)/sum(discwt) as rate1000

from library.nismicathcabg4

where pcionly or diagcathonly or cabgonly

group by pcionly, diagcathonly, cabgonly, gender;

select * from rates1000;

quit;

the previous error message was due to an extra semicolon in the SQL command.

PG

PG
Regular Contributor
Posts: 180

great!! it works this time thanks much.

and here is the table:

pcionly  diagcathonly  cabgonly  Indicator of sex  rate1000

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

0             0         1   0: Male           37.4785

0             0         1   1: Female        47.03301

0             1         0   0: Male            40.306

0             1         0   1: Female        34.44367

1             0         0   0: Male          24.12066

1             0         0   1: Female         38.5679

so this will be interpreted as mortality per 1000 (like  37 male patients per 1000  male patients or per 1000 total patient (regardless of gender)???  dying after a procedure.

Also these numbers are way off than what i got by just multiplying the percentages in the tables posted earlier...

just curious to know if my way was a wrong way to get the rate per 1000? but logically it seems right to me.. and its easy too.. I would like to know why we cannt use that method to calculate rate per 1000?

Any input on this?

Super User
Posts: 20,731

I might be missing something, but the unadjusted rate is typically when you want to measure the effect of treatment on a probability, ie probability of dying in the hospital.

So the unadjusted rate is the rate of the poeple who get the die in the hospital given specific treatments. Then you start 'adjusting' for age, sex and those are the rates of people who die in the hospital, adjusted for sex and age etc. I'd be using some form of logistic regression and odds ratio rather than just rates but that's me.

But I might totally be missing the context/question here.

Then you could say for example:

Overall odds of dying in a hospital are 10%, after adjusting for age the odds of dying based onthis treatment is x% after adjusting for sex is xx%.

Not to repeat myself, but I still really feel like I'm missing some key info to answer the question properly.

Discussion stats
• 26 replies
• 846 views
• 0 likes
• 6 in conversation