01-10-2013 04:58 AM
Here's one that Excel can do, so I'll use Excel if no fairly easy SAS way is possible.
Note following portion of data set:
Focus only on the Var_1 and Var_2 columns..., at least for the time being.
I need to "swap" the contents of the bottom four rows of cells.
Does SAS have a way to do this -- without your having to write tons of code?
01-10-2013 05:08 AM
There is no data step swap function (I've occasionally wished for it) but you can temporarily create another column say temp, then use code such as
If (condition to select rows to swap)
then do ;
temp = Var_1 ;
Var_1 = Var2 ;
Var_2 = temp ;
drop temp ;
You can also do it in sql, without creating a temp column but it is a lot more verbose.
01-10-2013 05:12 AM
Unclear where you write the line for tons , but here goes (assuming that you need to store column with values <> 0 in one column):
set var_2 = var_1
where var_1 <> 0 and var_2 = 0
Comparing to Excel is puzzling me. Excel is great when doing minor ad-hoc stuff, SAS is suited for developing programs that can be used multiple times, in batch etc.