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

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
SAS Enterprise Guide vs. SAS Studio

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1169 views
  • 0 likes
  • 4 in conversation