Hi there, I have the following data:
1 1
2 1
3 1
4 1
5 1
6 2
7 2
8 1
9 1
10 3
11 3
12 3
13 4
14 4
15 4
16 4
etc
where column 1 is userid and column 2 is whether it is unique or not (thus, users 13-16 are duplicates, 10-12 are duplicates, and 6 and 7 are duplicates. I need an output variable labeling each user as a unique value, so something like this:
1 1 1
2 1 2
3 1 3
4 1 4
5 1 5
6 2 6
7 2 6
8 1 7
9 1 8
10 3 9
11 3 9
12 3 9
13 4 10
14 4 10
15 4 10
16 4 10
Thanks!
That is a strange structure. Also what are the NAMES of those variables?
data want ;
set have ;
by var2 notsorted ;
var3 + (first.var2 or var2=1);
run;
That is a strange structure. Also what are the NAMES of those variables?
data want ;
set have ;
by var2 notsorted ;
var3 + (first.var2 or var2=1);
run;
I agree it's strange, why I needed to find a way out of it. And you have provided just that! Cheers!
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.