BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Sathish_jammy
Lapis Lazuli | Level 10

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!

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

If your data is sorted, do this

 

data want;
   set have;
   by G_Type;
   if first.G_Type then want + 1;
run;

View solution in original post

2 REPLIES 2
PeterClemmensen
Tourmaline | Level 20

If your data is sorted, do this

 

data want;
   set have;
   by G_Type;
   if first.G_Type then want + 1;
run;
RichardDeVen
Barite | Level 11

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 ?

Ready to join fellow brilliant minds for the SAS Hackathon?

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!
How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 433 views
  • 0 likes
  • 3 in conversation