BookmarkSubscribeRSS Feed
ManitobaMoose
Quartz | Level 8

Hi.

 

I am trying to display the computed variable Hypertensive such that it is shown as "Hypertensive?" and is computed as 'Yes' or 'No' depending on conditional factors.

 

First of all, I am getting no display for yes or no if I leave the variable name as Hypertensive, as opposed to displaying Hyertensive?

Second, I have no idea how to convert the variable hypertensive to display hypertensive? in proc report.

 

 

Any help would be much appreciated. Thanks!

 

-----------------------------------

Libname Learn '/folders/myfolders/Learn' ;

Title "Hypertensive Patients" ;
proc report data=learn.BloodPressure nowd headline ls=80 ;
    columns Gender SBP DBP Hypertensive ;
    define SBP            / display "SBP" ;
    define DBP            / display "DBP" ;
    compute Hypertensive  / character length=8 ;
    define Hypertensive   / display "Hypertensive?" ;
        If Gender=F then do ;
            If (SBP gt 138 or DBP gt 88) then Hypertensive='Yes';
            else Hypertensive='No' ;
        end ;
        If Gender=M then do ;
            If (SBP gt 140 or DBP gt 90) then Hypertensive='Yes';
            else Hypertensive='No' ;
        end ;
    endcomp ;
run ;

4 REPLIES 4
ChrisNZ
Tourmaline | Level 20

Like this?

 


proc report data=SASHELP.CLASS(obs=10);
    columns NAME SEX WEIGHT HYPERTENSIVE;
    compute HYPERTENSIVE  / character length=8 ;
        if SEX='F' then do ;
            if (WEIGHT.sum gt 100 ) then HYPERTENSIVE='Yes';
            else HYPERTENSIVE='No' ;
        end ;
        if SEX='M' then do ;
            if (WEIGHT.sum gt 110 ) then HYPERTENSIVE='Yes';
            else HYPERTENSIVE='No' ;
        end ;
    endcomp ;
run ;

 


Name Sex Weight HYPERTENSIVE
Alfred M 112.5 Yes
Alice F 84 No
Barbara F 98 No
Carol F 102.5 Yes
Henry M 102.5 No
James M 83 No
Jane F 84.5 No
Janet F 112.5 Yes
Jeffrey M 84 No
John M 99.5 No

 

 

ManitobaMoose
Quartz | Level 8

Thanks.

 

As for getting the hypertensive to display 'true' or 'false', it was simple:

I did not put the gender ='f' and gender='m' in apostrophes, as I should have for a character variable. When I corrected this, after reading your post, it worked.

 

As for converting the variable hypertensive to hypertensive? for displaying on the proc report, I am not sure how to do this. However, I did get most of it. If anyone else has suggestions on this that would be great. If not, that is ok.

ManitobaMoose
Quartz | Level 8

Libname Learn '/folders/myfolders/Learn' ;

Title "Hypertensive Patients" ;
proc report data=learn.BloodPressure nowd headline ls=80 ;
    columns Gender SBP DBP Hypertensive ;
    define SBP            / display "SBP" ;
    define DBP            / display "DBP" ;
    compute Hypertensive  / character length=8 ;
        If Gender='F' then do ;
            If (SBP gt 138 or DBP gt 88) then Hypertensive='Yes';
            else Hypertensive='No' ;
        end ;
        If Gender='M' then do ;
            If (SBP gt 140 or DBP gt 90) then Hypertensive='Yes';
            else Hypertensive='No' ;
        end ;
    endcomp ;
    hypertensive(rename=hypertensive?) ;
run ;

andreas_lds
Jade | Level 19

The question-mark  is not a valid char in a name. But you can assign a label to Hypertensive to be displayed as "Hypertensive?"

 

proc report data=SASHELP.CLASS(obs=10);
    columns NAME SEX WEIGHT HYPERTENSIVE;

    define HYPERTENSIVE / computed "Hypertensive?";

    compute HYPERTENSIVE  / character length=8 ;
        if SEX='F' then do ;
            if (WEIGHT.sum gt 100 ) then HYPERTENSIVE='Yes';
            else HYPERTENSIVE='No' ;
        end ;
        if SEX='M' then do ;
            if (WEIGHT.sum gt 110 ) then HYPERTENSIVE='Yes';
            else HYPERTENSIVE='No' ;
        end ;
    endcomp ;
run ;

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register 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.

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
  • 738 views
  • 0 likes
  • 3 in conversation