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

Looking to see if anyone knows of an easy way to do the following...

I have a format set up for ranges on "score".

I do a proc freq on score and see the ranges for my scores.  Now, I'm being requested to show ALL my ranges, regardless of whether or not a score is present.  If a score does not exist for a range then it should show as zero.  Example below:

  Proc format ;

  value scorefmt

     0 -< 10 = "0 - 10"

     10 -< 20 = "10 - 20"

     20 -< 30 = "20 - 30"

     30 -< 40 = "30 - 40"

     40 - HIGH = "40+" ;

  run ;

data dataset1 ;

  length score 8 ;

  input score ;

  format score scorefmt. ;

  datalines ;

1

10

11

19

45

;

  run ;

 

proc format data = dataset1 ;

  tables score / list missing ;

  run ;

shows:

                                                        Cumulative    Cumulative

  score    Frequency     Percent     Frequency      Percent
ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ

0 - 10            1       20.00             1        20.00

10 - 20           3       60.00             4        80.00

40+               1       20.00             5       100.00

What I would LIKE to see:

                                                        Cumulative    Cumulative

  score    Frequency     Percent     Frequency      Percent
ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ

0 - 10            1       20.00             1        20.00

10 - 20           3       60.00             4        80.00

20 - 30          0          0                    4     80.00

40+               1       20.00             5       100.00

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

You want a procedure that lets you use PRELOADFMT option for class type variables. Which means procs tabulate, report or means.

Roughly equivalent for your freq, though it doesn't generate the cumulative bits

proc tabulate data=dataset1;

class score /preloadfmt missing;

format score scorefmt.;

table score, n pctn / printmiss;

run;

View solution in original post

3 REPLIES 3
Peter_C
Rhodochrosite | Level 12

CompleteTypes

ballardw
Super User

You want a procedure that lets you use PRELOADFMT option for class type variables. Which means procs tabulate, report or means.

Roughly equivalent for your freq, though it doesn't generate the cumulative bits

proc tabulate data=dataset1;

class score /preloadfmt missing;

format score scorefmt.;

table score, n pctn / printmiss;

run;

jtb
Calcite | Level 5 jtb
Calcite | Level 5

Thanks so much!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 3 replies
  • 1113 views
  • 0 likes
  • 3 in conversation