I currently have this PROC SQL code:
TITLE "Subjects with High Blood Pressure (> 140 mmHg) (Ordered by Descending SBP)";
PROC SQL NUMBER;
SELECT StateCd LABEL = "State",
SSN LABEL = "Soc Sec #",
SBP LABEL = "Systolic BP",
BMI,
ICD10 LABEL = "ICD 10 Code"
FROM HypAnl.HypPrimAnl
WHERE SBP > 140
ORDER BY SBP DESC;
QUIT;
QUIT;
I have BMI variables that currently have one decimal that I want to be rounded to the nearest whole number. I also want my ICD.10 variable to go from the format B33.19 to just B33, so basically just a substring of this variable. I have been told to do this using formats even though my first thought was to use functions. Any thoughts on the best way to do this?
TITLE "Subjects with High Blood Pressure (> 140 mmHg) (Ordered by Descending SBP)";
PROC SQL NUMBER;
SELECT StateCd LABEL = "State",
SSN LABEL = "Soc Sec #",
SBP LABEL = "Systolic BP",
round(BMI, 1.0) as BMI,
scan(ICD10,1,'.') as ICD10 LABEL = "ICD 10 Code"
FROM HypAnl.HypPrimAnl
WHERE SBP > 140
ORDER BY SBP DESC;
QUIT;
It depends what you want - functions will change the actual value in the field whereas formats only change the way that value is displayed.
TITLE "Subjects with High Blood Pressure (> 140 mmHg) (Ordered by Descending SBP)";
PROC SQL NUMBER;
SELECT StateCd LABEL = "State",
SSN LABEL = "Soc Sec #",
SBP LABEL = "Systolic BP",
round(BMI, 1.0) as BMI,
scan(ICD10,1,'.') as ICD10 LABEL = "ICD 10 Code"
FROM HypAnl.HypPrimAnl
WHERE SBP > 140
ORDER BY SBP DESC;
QUIT;
That worked, thanks!
Format for numbers, functions for strings:
TITLE "Subjects with High Blood Pressure (> 140 mmHg) (Ordered by Descending SBP)";
PROC SQL NUMBER;
SELECT
StateCd LABEL = "State",
SSN LABEL = "Soc Sec #",
SBP LABEL = "Systolic BP",
BMI format=6.0,
scan(ICD10, 1, ".") LABEL = "ICD 10 Code"
FROM HypAnl.HypPrimAnl
WHERE SBP > 140
ORDER BY SBP DESC;
QUIT;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.