I have a dataset that looks like this:
| ID | group | |
| 1 | AB | |
| 1 | AB | |
| 2 | CD | |
| 2 | CD | |
| 3 | CD | |
| 3 | CD | |
| 4 | EF |
What i would like to do see assign 1 for unique ID with group . if it is repeated more than once, then 0
something else this
| ID | group | count |
| 1 | AB | 1 |
| 1 | AB | 0 |
| 2 | CD | 1 |
| 2 | CD | 0 |
| 3 | CD | 1 |
| 3 | CD | 0 |
| 4 | EF | 1 |
i was thinking to do proc sql like proc sql; select distinct id, group, 1 as count; quit;
but was wondering if there is a simple dataset command where i dont have to create another dataset
thanks!
d
COUNT is probably not a good name for a variable with values like that. If looks like the same values as the FIRST. variable that is created for BY group processing. Looks like both ID and GROUP have the same meaning, just that one is a number and the other is a string.
data want ;
set have;
by id;
count=first.id;
run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.