BookmarkSubscribeRSS Feed
Joliek44
Calcite | Level 5

Hello!! 

Im on SAS 9.4

I am trying to run a logistical regression on systolic and diastolic blood pressure is associated with Cardiovascular risk. Question is: Investigate the association of blood pressure categories (i.e., normal, elevated, and hypertension) with CVD events after adjustment for age, BMI, and current smoking (Use the reference group as normal BP category).  Let’s set alpha as 0.05 level. 

I am having problems trying to write a SAS code for proc logist descending and I don't know how to enter info to do blood pressure, since have sysbp and diabp separate columns. How to write the proc format for blood pressures for normal, elevated and hypertension. Info-Classify all participants as normal (SYSBP/DIABP) (<120/80), elevated (120-129 and <80), and hypertension (>130 or >80) categories. And how to do the if, then statements.

Such as-

if sysbp <120 then sysbpc=1;

else if 120 <=sysbp <=129 then sysbpc=2;

else if sysbp>=130 then sysbpc=3;

 

if diabp <80 then diabpc=1;

else if diabp <80 diabpc=2;

else if diabp >=80 diabpc=3;

 

 

if sysbpc = 1 then do; sysbpc2 = 0; sysbpc3 = 0; end;

if sysbpc = 2 then do; sysbpc2 = 1; sysbpc3 = 0; end;

if sysbpc = 3 then do; sysbpc2 = 0; sysbpc3 = 1; end;


Any help would be appreciated. 

 

 

Data is arranged below:

  TOTCHOL AGE SYSBP DIABP CURSMOKE BMI DIABETES TIME HDLC LDLC CVD SEX
1 195 39 106 70 0 26.97 0 0 . . 1 1
2 209 52 121 66 0 . 0 4628 31 178 1 1
3 250 46 121 81 0 28.73 0 0 . . 0 0
4 260 52 105 69.5 0 29.43 0 2156 . . 0 0
5 237 58 108 66 0 28.5 0 4344 54 141 0 0
5 REPLIES 5
Reeza
Super User

To create your BP categories you can use IF/THEN within a single step.

I did add a CHECKME category so you can check if the coding misses categories, I tried to implement your rules but to be honest I don't think those are the right categories for blood pressure definitions. You should confirm how you're going to code BP and then hopefully you can change the code accordingly. 

 

data addBP;
set have; *assumes your input data set name is HAVE, replace accordingly;

if sysbp<120 and diabp = 80 then bp_status = 'Normal';
else if 120<=sysbp<=129 and diabp <80 then bp_status = 'Elevated';
else if sysbp>=130 and diabp>80 then bp_status = 'Hypertension';
else bp_status = 'CHECKME';

run;

*check your coding;
proc freq data=addBP;
table diasbp*sysbp*bp_status / list;
run;

*regression attempt;
proc logistic data=addBP;
class sex cursmoke bp_status (ref='Normal'); / param=REF;
model cvd (event='1') = age bmi cursmoke bp_status;
run;


@Joliek44 wrote:

Hello!! 

Im on SAS 9.4

I am trying to run a logistical regression on systolic and diastolic blood pressure is associated with Cardiovascular risk. Question is: Investigate the association of blood pressure categories (i.e., normal, elevated, and hypertension) with CVD events after adjustment for age, BMI, and current smoking (Use the reference group as normal BP category).  Let’s set alpha as 0.05 level. 

I am having problems trying to write a SAS code for proc logist descending and I don't know how to enter info to do blood pressure, since have sysbp and diabp separate columns. How to write the proc format for blood pressures for normal, elevated and hypertension. Info-Classify all participants as normal (SYSBP/DIABP) (<120/80), elevated (120-129 and <80), and hypertension (>130 or >80) categories. And how to do the if, then statements.

Such as-

if sysbp <120 then sysbpc=1;

else if 120 <=sysbp <=129 then sysbpc=2;

else if sysbp>=130 then sysbpc=3;

 

if diabp <80 then diabpc=1;

else if diabp <80 diabpc=2;

else if diabp >=80 diabpc=3;

 

 

if sysbpc = 1 then do; sysbpc2 = 0; sysbpc3 = 0; end;

if sysbpc = 2 then do; sysbpc2 = 1; sysbpc3 = 0; end;

if sysbpc = 3 then do; sysbpc2 = 0; sysbpc3 = 1; end;


Any help would be appreciated. 

 

 

Data is arranged below:

  TOTCHOL AGE SYSBP DIABP CURSMOKE BMI DIABETES TIME HDLC LDLC CVD SEX
1 195 39 106 70 0 26.97 0 0 . . 1 1
2 209 52 121 66 0 . 0 4628 31 178 1 1
3 250 46 121 81 0 28.73 0 0 . . 0 0
4 260 52 105 69.5 0 29.43 0 2156 . . 0 0
5 237 58 108 66 0 28.5 0 4344 54 141 0 0

 

Joliek44
Calcite | Level 5

Thank you Reeza, greatly appreciate your help. I did get a code but not sure what I'm missing. I know I'm not connecting one data to another. But, can't see what it is. 

 

ods html close;
ods html;

libname c 'C:\Users\mcbegay\Documents\ASU SAS Files';

proc format;
value sysbp_diabpcf 1='normal' 2='elevated' 3='hypertension';
value CVDf 1='yes' 0='no';

data cph;
set c.FHS;
followyr=(time/365.25); if followyr>=3;
sysbp_diabp=(sysbp/diabp);

if sysbp <120 or diabp < 80 then sysbp_diabp1c =1;
if 120<= sysbp <=129 or diabp <80 then sysbp_diabp2c =2;
if sysbp >=130 or diabp>80 then sysbp_diabp3c =3;

*sysbpc D1 D2;
*sysbp_diabp120_80 0 0;
*sysbp_diabp120_129_80 1 0;
*sysbp_diabp130_80 0 1;

if sysbp_diabpc = 1 then do; sysbp_diabp2 = 0; sysbp_diabp3 = 0; end;
if sysbp_diabpc = 2 then do; sysbp_diabp2 = 1; sysbp_diabp3 = 0; end;
if sysbp_diabpc = 3 then do; sysbp_diabp2 = 0; sysbp_diabp3 = 1; end;


format sysbp_diabp sysbp_diabpcf. cvd cvdf.;

proc phreg data=cph;
class sysbp_diabp;
model followyr*cvd(0)=sysbp_diabp2 sysbp_diabp3 bmi age cursmoke/rl;
run;

 

-Its now giving me this error code. 

NOTE: 7193 observations were deleted due either to missing or invalid values for the
time, censoring, frequency or explanatory variables or to invalid operations in
generating the values for some of the explanatory variables.
ERROR: There are no valid observations for the analysis.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE PHREG used (Total process time):
real time 0.04 seconds
cpu time 0.04 seconds

PaigeMiller
Diamond | Level 26

As we don't have your data (you only showed us a small portion of it), here's what you need to do. Look at the data set named CPH with your own eyes and see if there are missing values in there that might cause the ERROR message.

--
Paige Miller
Joliek44
Calcite | Level 5

Well, that's what it was listed under from class. My bad. I am taking bio-statistics and there was no mention of needing to know SAS program. And our professor is no help. Just sends us to websites that don't make sense. So, its been a learn by the fly for me here. It is proc phreg Hazard Ratio question. I been doing the SAS classes but have not gotten this far. 

Reeza
Super User
Ok...you didn't use the code I provided and you're now doing Cox regression, not logistic regression. I'm not sure what the question is anymore.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 5 replies
  • 1728 views
  • 0 likes
  • 3 in conversation