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 ?
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
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.