my data set has following variables
x1 x2 x3 x4....x100 Month
How do I rearrange so that the following happens:
Month x1 x2 x3 x4....x100
In other words I need to rearrange so that Month is the first column. But I don't want to have to write down all other
100 variables (i actually have over 7,000 variables).
Thanks in advance!
Here is a reference that illustrates how to refer to variables and datasets in a short cut list:
https://blogs.sas.com/content/iml/2018/05/29/6-easy-ways-to-specify-a-list-of-variables-in-sas.html
data want;
retain month x1-x100;
set have;
run;
@ubshams wrote:
my data set has following variables
x1 x2 x3 x4....x100 Month
How do I rearrange so that the following happens:
Month x1 x2 x3 x4....x100
In other words I need to rearrange so that Month is the first column. But I don't want to have to write down all other
100 variables (i actually have over 7,000 variables).
Thanks in advance!
With 7,000 variables, I'm imagining that they are not necessarily named x1-x7000. You can shortcut the code and move MONTH to the first position just using:
data want;
retain month;
set have;
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.