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

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 1920 views
  • 1 like
  • 4 in conversation