BookmarkSubscribeRSS Feed
ferlopz298
Calcite | Level 5

Hi,

    I am new to SAS and wanted to get some feedback on a problem. I am only in Chapter 2 so I have a lot to learn still. I am stuck on a problem and need help to understand how the code should be formatted. I think my order of operations is off with the math portion causing errors. See below, for the scenario the book has listed and the code I entered. I appreciate any feedback! I don't want to get discouraged and give up but I don't have a teacher to explain these things to me either. PLEASE HELP!

 

2. Given the program here, add the necessary statements to compute four new variables:

a. Weight in kilograms (1 kg=2.2 pounds). Name this variable WtKg.

b. Height in centimeters (1 inch=2.54 cm). Name this variable HtCm.

c. Average blood pressure (call it AveBP) equal to the diastolic blood pressure plus one-third the difference of the systolic blood pressure minus the diastolic blood pressure. 

d. A variable (call it HtPolynomial) equal to 2 times the height squared plus 1.5 times the height cubed.

 

Code:

 

data prob2;
input ID$
Height /* in inches */
Weight /* in pounds */
SBP /* systolic BP */
DBP /* diastolic BP */;
HtCm=1 inch = 2.54 cm;
WtKg=1 kg = 2.2 pounds;
AveBP=DBP+1/3(SBP-DBP);
HtPolynomial=2*HtCm**+1.5*HtCm***;
cards;
001 68 150 110 70
002 73 240 150 90
003 62 101 120 80
;
title 'listing of prob2';
proc print data=prob2;
run;

1 REPLY 1
PaigeMiller
Diamond | Level 26

I'll show you the proper code for converting height to cm. You can take that and figure out the other ones.

HtCm=2.54 * height;

 

--
Paige Miller

Catch up on SAS Innovate 2026

Dive into keynotes, announcements and breakthroughs on demand.

Explore Now →
Develop Code with SAS Studio

Get started using SAS Studio to write, run and debug your SAS programs.

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
  • 1 reply
  • 1971 views
  • 0 likes
  • 2 in conversation