Create a new data set for each BY-Group in a data set

/ Published in: SAS
Save to your folder(s)

This sample uses macro logic to determine the number of unique values of a variable (the BY variable) and creates a new data set for each. The resulting data set names will be the BY variable value.


The sample code does not allow for BY values of longer than 32 positions, numeric BY values or BY values that contain characters that are not permitted in SAS data set names.

If your data contains any of the above, you must add program statements to convert your BY values into valid SAS data set names.


Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.