Hi Experts,
I need to create the group type in numbers for the following dataset
data have;
input G_Type$10.;
cards;
ABI
ABI
BIG
BIG
BIG
RET
run;
Expected output:
G_Type | Want |
ABI | 1 |
ABI | 1 |
ABI | 1 |
BIG | 2 |
BIG | 2 |
BIG | 2 |
RET | 3 |
Thanks in advance!
If your data is sorted, do this
data want;
set have;
by G_Type;
if first.G_Type then want + 1;
run;
If your data is sorted, do this
data want;
set have;
by G_Type;
if first.G_Type then want + 1;
run;
G_TYPE appears to be already ordered in an ascending manner.
Is there a reason you can't use G_TYPE directly?
Are you using 'want' to maintain original G_TYPE order ?
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: