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;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: