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


Is this format correct?

25th percentile is 5.2833

i want all the ones less than 25th percentile and

greater than or equal to 25th in the other???

proc format;

value $graftsfmt

0-<5.2833="<25th Percentile"

5.2833-high=">=25th Percentile"

;

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Depends on what you mean by correct. It'll work but does it give you what you want.

You need to check it with either your data or some test data to see if it's what you want.

Here's a way to test it with sample data, notice the boundary value tests and then the negative numbers:

data test;

format a 20.8;

input a;

cards;

-2.345

3.2342

5.2381

5.2382

5.2382134

5.23825

5.2382767

5.2833

5.2833124

5.28335

5.28335789

5.2834

5.3432

6.2343

;

run;

proc format;

value graftsfmt

0-<5.2832="<25th Percentile"

5.2833-high=">=25th Percentile"

;

data want;

    set test;

    b=a;

    format b graftsfmt.;

run;

proc freq data=want;

table a*b/missing;

run;

View solution in original post

4 REPLIES 4
ballardw
Super User

You are currently making a STRING format, Change the value statement to: value graftsfmt

to allow use with numeric variables.

robertrao
Quartz | Level 8

Thanks for the reply....Other than that do you think this is also correct?

proc format;

value graftsfmt

0-<5.2832="<25th Percentile"

5.2833-high=">=25th Percentile"

;

Reeza
Super User

Depends on what you mean by correct. It'll work but does it give you what you want.

You need to check it with either your data or some test data to see if it's what you want.

Here's a way to test it with sample data, notice the boundary value tests and then the negative numbers:

data test;

format a 20.8;

input a;

cards;

-2.345

3.2342

5.2381

5.2382

5.2382134

5.23825

5.2382767

5.2833

5.2833124

5.28335

5.28335789

5.2834

5.3432

6.2343

;

run;

proc format;

value graftsfmt

0-<5.2832="<25th Percentile"

5.2833-high=">=25th Percentile"

;

data want;

    set test;

    b=a;

    format b graftsfmt.;

run;

proc freq data=want;

table a*b/missing;

run;

TomKari
Onyx | Level 15

Also, I suggest setting the FUZZ to zero.

value graftsfmt (fuzz=0)

See the following for a fuller discussion:

https://communities.sas.com/message/141317#141317

Tom

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

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
  • 777 views
  • 6 likes
  • 4 in conversation