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

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 600 views
  • 0 likes
  • 2 in conversation