Hi Everyone,
I have a data file like
data have;
input var x_1 x_3 x_bac x_1dnx b ;
datalines;
0 1 1 1 1 0
;
run;
I want to put all X_ to the end, since there are hundred of X_ variable and they follow no rule other than the prefix of X_, is there any way to do it quicky?
Thank you,
HHC
data reorder;
if 0 then set have(drop=x_:);
set have;
run;
data reorder;
if 0 then set have(drop=x_:);
set have;
run;
@data_null__ very cool solution 🙂
Just to understand, when we use the if 0 trick, we make sure that whatever follows is only done in compilation right?
@PeterClemmensen wrote:
@data_null__ very cool solution 🙂
Just to understand, when we use the if 0 trick, we make sure that whatever follows is only done in compilation right?
Correct.
@hhchenfx wrote:
Hi Data_null_,
Interesting indeed!
But what does the "if 0" do to the code?
Thank you,
HHC
It is an expression that is FALSE preventing the SET statement from being executed. The SET statement is compiled which places variables in the PDV in the desired order.
Thank you for your help!
HHC
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.