## Getting all the values in a single variable

Solved
Occasional Contributor
Posts: 8

# Getting all the values in a single variable

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 "-")

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

Accepted Solutions
Solution
‎03-15-2016 12:19 PM
Super User
Posts: 6,785

## Re: Getting all the values in a single variable

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

data want;

do until (last.name);

set have;

by name;

end;

do until (last.name);

set have;

by name;

output;

end;

run;

All Replies
Super User
Posts: 23,771

## Re: Getting all the values in a single variable

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

Also...look at the scan function.

Solution
‎03-15-2016 12:19 PM
Super User
Posts: 6,785

## Re: Getting all the values in a single variable

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

data want;

do until (last.name);

set have;

by name;

end;

do until (last.name);

set have;

by name;

output;

end;

run;

Occasional Contributor
Posts: 8

## Re: Getting all the values in a single variable

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

Super User
Posts: 13,583

## Re: Getting all the values in a single variable

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

🔒 This topic is solved and locked.