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;
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;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.