BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
HSM9
Calcite | Level 5

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Shmuel
Garnet | Level 18
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;

View solution in original post

4 REPLIES 4
ChrisBrooks
Ammonite | Level 13

It depends what you want - functions will change the actual value in the field whereas formats only change the way that value is displayed.

Shmuel
Garnet | Level 18
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;
HSM9
Calcite | Level 5

That worked, thanks!

PGStats
Opal | Level 21

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;
PG
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
  • 4 replies
  • 2097 views
  • 0 likes
  • 4 in conversation