BookmarkSubscribeRSS Feed
iSAS
Quartz | Level 8

Let's say I have a data below:

 

data have;
infile cards truncover;
input ID :$4.;
cards;
0196
0196
0196
0395
0752
1277
1277
;
run;

 

What I want is to have a new table with a new column wherein it will count the number of times the ID appeared but not group it. To explain it clearer, I want to have an output like this:

ID        Count_ID
0196          1
0196          2
0196          3
0395          1
0752          1
1277          1
1277          2

 

Could someone help me on this? A program that will work even if ID is not sort by order

1 REPLY 1

SAS Innovate 2025: Register Now

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!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 424 views
  • 0 likes
  • 2 in conversation