I cannot figure out where I am going wrong in the problem below. I know it's something I'm overlooking.
/*2 Given the programs here, add the necessary statements to compute the four new variables. */
*a /Weight in kilograms (1kg = 2.2 pounds). Name this variable WtKg/;
*b /Height in centimenters (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 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. */;
DATA Prob2;
INPUT ID $
Height /* in inches */
Weight /* in pounds */
SBP /* systolic B P */
DBP /* diastolic B P */;
Wtkg = Weight/2.2;
HtCm = Height/2.54;
AveBP = DBP + 1/3SBP - DBP;
HtPolynomial = 2 *Height**2 + 1.5 *Height**3;
DATALINES;
001 68 150 110 70
002 73 240 150 90
003 62 101 120 80
;
TITLE "Listing of Prob2";
PROC PRINT DATA = Prob2;
Run;
AveBP = DBP + 1/3SBP - DBP;
That's probably not what you want, and it's where SAS generated the error.
Second, review how you're converting height. Would you expect height in cm to be lareger than height in inches? Your conversion is likely backwards.
@tmjeffer wrote:
I cannot figure out where I am going wrong in the problem below. I know it's something I'm overlooking.
/*2 Given the programs here, add the necessary statements to compute the four new variables. */
*a /Weight in kilograms (1kg = 2.2 pounds). Name this variable WtKg/;
*b /Height in centimenters (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 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. */;
DATA Prob2;
INPUT ID $
Height /* in inches */
Weight /* in pounds */
SBP /* systolic B P */
DBP /* diastolic B P */;
Wtkg = Weight/2.2;
HtCm = Height/2.54;
AveBP = DBP + 1/3SBP - DBP;
HtPolynomial = 2 *Height**2 + 1.5 *Height**3;
DATALINES;
001 68 150 110 70
002 73 240 150 90
003 62 101 120 80
;
TITLE "Listing of Prob2";
PROC PRINT DATA = Prob2;
Run;
Post your new code and log, and remember order of operations so make sure you have parenthesis where you need them.
@tmjeffer wrote:
I put parentheses around (SBP -DBP) First and couldn’t get it to read either.
Listing of Prob2 |
001 | 68 | 150 | 110 | 70 | 68.182 | 172.72 | 83.333 | 480896.0 |
002 | 73 | 240 | 150 | 90 | 109.091 | 185.42 | 110.000 | 594183.5 |
003 | 62 | 101 | 120 | 80 | 45.909 | 157.48 | 93.333 | 365180.0 |
/*2 Given the programs here, add the necessary statements to compute the four new variables. */
*a /Weight in kilograms (1kg = 2.2 pounds). Name this variable WtKg/;
*b /Height in centimenters (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 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. */;
DATA Prob2;
INPUT ID $
Height /* in inches */
Weight /* in pounds */
SBP /* systolic B P */
DBP /* diastolic B P */;
Wtkg = Weight/2.2;
HtCm = Height*2.54;
AveBP = DBP + 1/3 *(SBP - DBP);
HtPolynomial = 2 * (Height)**2 + 1.5 * (Height)**3;
DATALINES;
001 68 150 110 70
002 73 240 150 90
003 62 101 120 80
;
TITLE "Listing of Prob2";
PROC PRINT DATA = Prob2;
Run;
Hello,
I need to convert inches to cm in some of my data, it is a mixed bag of inches and cms.
my variables
comor_9hgtunit_decode = says whether it is in inches or cm
comor_9hgtunit gives 1 for cm and 2 for inches
comor_9hgt = measurements in inches or cms
Here is how I approached it.
data demo2;
set mergedata;
If comor_9htunit then do;
height_cm = comor_9ht/2.54;
end;
else do;
height_cm =comor_9ht;
end;
run;
I am getting the error code WARNING: The data set WORK.DEMO2 may be incomplete. When this
step was stopped there were 0 observations and 3
variables.
If comor_9htunit then do;
Is this statement true, or false, when comor_9htunit=1?
Is this statement true, or false, when comor_9htunit=2?
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.