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 ?
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.