BookmarkSubscribeRSS Feed
marksanter
Obsidian | Level 7
 

Hello,

 

What is the best way to create custom frequency bins? 

6 REPLIES 6
Reeza
Super User
What about the 10's? Ignore them completely?

Have you looked into multilevel formats yet? I would highly recommend using a mlf to get this result, which becomes quite simple.
marksanter
Obsidian | Level 7

Hello,

I have not looked into MLFs. I am still quite new to SAS.

Mark

ballardw
Super User

I haven't a clue what role the date plays in this.

 

Can you provide something with the counts done manually from the example data?

marksanter
Obsidian | Level 7
My apologies, the date does not really play a role in this dataset.

May I ask what you mean by providing something with the counts done
manually?
Reeza
Super User
It means show what you expect as the final result from this data. Then we can test our programs to ensure they get the right result otherwise we're making guesses and this becomes a longer back and forth process.
PGStats
Opal | Level 21

Keep it simple:

 

data counts;
do n = 1 by 1 until(last.count);
    set have; 
    by count notsorted;
    end;
if count = 5 then do;
    do bin = 1 to 141 by 10;
        if n >= bin then output;
        end;
    end;
keep n bin;
run;

proc sql;
create table want as
select
    bin,
    count(n) as nbSequences,
    sum(n) as nb5Counts
from counts
group by bin;
quit;

proc print data=want noobs; run;
                                      nb
                           bin    Sequences    nb5Counts

                             1        5           155
                            11        2           135
                            21        2           135
                            31        2           135
                            41        2           135
                            51        2           135
                            61        1            81
                            71        1            81
                            81        1            81
PG

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!

Register now

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 6 replies
  • 2115 views
  • 1 like
  • 4 in conversation