BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Daya87
Calcite | Level 5

I Have a Data Like below table. I Just Had only name and Grade. Need to create All_Grades(Individual Grades should come seperated by "-")

 Name    Grade      All_Grades
Alfred        A           A-B-C-A-D
Alfred        B           A-B-C-A-D
Alfred        C           A-B-C-A-D
Alfred        A           A-B-C-A-D
Alfred        D           A-B-C-A-D
James       B           B-C-A
James       C           B-C-A
James       A           B-C-A
Philip         D           D-C-A-A
Philip         C           D-C-A-A
Philip         A           D-C-A-A
Philip         A           D-C-A-A
William      A           A-A-C
William      A           A-A-C
William      C           A-A-C

 

 

 

 

Thanks in advance

 

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

Here's one way, assuming that your data is sorted by NAME:

 

data want;

length all_grades $ 20;

do until (last.name);

   set have;

   by name;

   all_grades = catx('-', all_grades, grade);

end;

do until (last.name);

   set have;

   by name;

   output;

end;

run;

View solution in original post

4 REPLIES 4
Reeza
Super User

Please post what you'd like the output to be, for clarification.

 

Also...look at the scan function. 

 

Astounding
PROC Star

Here's one way, assuming that your data is sorted by NAME:

 

data want;

length all_grades $ 20;

do until (last.name);

   set have;

   by name;

   all_grades = catx('-', all_grades, grade);

end;

do until (last.name);

   set have;

   by name;

   output;

end;

run;

Daya87
Calcite | Level 5

Yes, It's working Fine. Thanks a lot.

ballardw
Super User

Please mark the appropriate response as your accepted solution.

 

This helps other users know that a correct or acceptable answer for a given problem has been posted.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 4 replies
  • 909 views
  • 2 likes
  • 4 in conversation