This is a bit of a weird request....I have some data on aircraft flights that I need to break out depending on how many times they appear in a group. The group is identified as follows:
daily_grouping
104042452
104042452
104042452
104042452
104042452
104042452
104042453
104042454
104042455
104042455
104042456
104042456
104042456
There are other variables as well, but the daily_grouping is the one to key in on. Here is what I would like:
1. If a daily_grouping number appears only once, it should be removed.
2. If a daily_grouping number appears more than once, then the first instance should be removed and n-1 should remain.
This means that in the example above the result would be:
daily_grouping
104042452
104042452
104042452
104042452
104042452
104042455
104042456
104042456
Any help would be appreciated! Not sure if multiple steps are needed.
data have; input daily_grouping :$10.; datalines; 104042452 104042452 104042452 104042452 104042452 104042452 104042453 104042454 104042455 104042455 104042456 104042456 104042456 ; data want; set have; by daily_grouping; if not first.daily_grouping; run;
data have; input daily_grouping :$10.; datalines; 104042452 104042452 104042452 104042452 104042452 104042452 104042453 104042454 104042455 104042455 104042456 104042456 104042456 ; data want; set have; by daily_grouping; if not first.daily_grouping; run;
data have; input daily_grouping :$10.; datalines; 104042452 104042452 104042452 104042452 104042452 104042452 104042453 104042454 104042455 104042455 104042456 104042456 104042456 ; proc sort data=have dupout=want nodupkey; by daily_grouping ; run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.