DATA Step, Macro, Functions and more

move a column to be the first one

Reply
Frequent Contributor
Posts: 77

move a column to be the first one

This is usually how I did when I want to move a column to be the first column in the dataset:


data a2;
retain idx;
set a1;
idx = _n_;
run;

Is there any better way to do this in data steps?
Super User
Posts: 9,687

Re: move a column to be the first one

Then Should use this;
[pre]


data temp;
idx=_n_;
set sashelp.class;
run;
[/pre]


Ksharp
Contributor
Posts: 33

Re: move a column to be the first one

I'm glad you asked this because I've needed to do this and didn't know how! Thanks!
Contributor
Posts: 33

Re: move a column to be the first one

I'm glad you asked this because I've needed to do this and didn't know how! Thanks!
Contributor
Posts: 24

Re: move a column to be the first one

length or format statement works also.
Ask a Question
Discussion stats
  • 4 replies
  • 253 views
  • 0 likes
  • 4 in conversation