I want to count the number of times each id appears in the whole dataset.
data example:
data have;
input id var1 var2;
datalines;
1 0 0
1 0 0
1 1 0
1 0 1
1 1 1
2 0 0
2 1 0
2 1 1
3 1 0
3 0 1
3 0 1
4 0 0
4 1 0
4 0 1
4 1 1
;
run;
What I want:
data want; input id count; datalines; 1 5 2 3 3 3 4 4 ; run;
Counting is a job for PROC FREQ
proc freq data=have;
tables id/noprint out=counts(keep=count id);
run;
Visualization was not mentioned in your original message. Visualization for what purpose? What type of visualization are you talking about ... please describe in more detail, or show us an example (perhaps from the Internet).
My main goal is to know what is the frequency of the repetition of ids. So all the ids that appear once can be grouped, twice another group, etc.
You could sort the output data set, which I named COUNTS, by the variable named COUNT.
Not really understanding here. You have millions of observations, you cannot look at them in any reasonably comprehensive way. You said:
My main goal is to know what is the frequency of the repetition of ids. So all the ids that appear once can be grouped, twice another group, etc.
And then I gave a suggestion on how to do this. If that doesn't work for you, DESCRIBE in a lot more detail what you want, or better yet, show us. Don't make me guess. Don't use words like "visualize" which means different things to different people and doesn't make sense to me in this situation.
Run a second PROC FREQ on the result dataset of the first.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.