01-19-2012 06:17 AM
pardon me for butting in ;-)
I would like to suggest a significant change to this "standard" re-ordering.
Rather than re-create the data in the order required (this time?) create a VIEW.
Then only when columns are being read will that data be rearranged.
(and it probably makes no difference to the performance of reading the data)
OK a view might require a little storage, but probably very very little.
Once the concept is accepted, a few advantages become apparent!
For a substantial (or even BIG) data set - expect to make more than one re-arrangement - it's only another VIEW!
Create VIEWS for every new order requested.
Obviously the VIEW process will vary only in the order required and the name of the VIEW to be created. So that suggests a macro. Perhaps it might be as simple as your code wrapped in a macro like:
%macro new_view( data= input_table, VIEW= new_VIEW, columns= a b c ) ;
data &VIEW / view= &VIEW ;
retain &columns ;
set &data ;
but you know me ...
for a basic capability, I expect it to be reused many times until, it is used by those who might not understand it so well. Preparing for that, I add checks that the input exists, and can be opened, and the output is not already in existence (unless the caller adds a parameter to confirm "replace") so I tested the macro %new_view, attached as the file new_view.sas
%new_view( data= sashelp.vformat, view= sasuser.vformat, columns fmtName fmtType minw defw maxw mind defd maxd );
01-18-2012 10:57 AM
using retain statement:
set sashelp.class (obs=5);
retain height weight age name sex;
Need further help from the community? Please ask a new question.