I have a dataset with 3 variables only and one variable is area name which has 100+ different areas. Is there an easy way of splitting the dataset into 100+ datasets instead of stacks of code.
I know how to do it using a macro but need to know how to create macro-variables from the area name variable attributes and loop into the macro rather than typing each one out.
surely the forecasting application supports by-processing and classing?
You may find other forums more helpful.
Although it is a xxxxxxxx to manage them, it is easy to create hundreds of data sets[pre] data rest %gen( pattern= data.area###, from=1, upto= 1000 ) ;
set original.data_set ;
select (area) ;
%gen( pattern= %str( when ( ### ) output data.area### ; )
, from=1, upto= 1000 )
otherwise output rest ;
That will split the table original.data_set into up to 1001 datasets assuming that rows with "area" having value, say 23, should be written into table data.area23 .
Any rows with area outside the range 1-1000 will be written to table work.rest.
The code assumes you have a macro %GEN() available that works by replacing ### in a pattern with a number varying from &from to &upto. Something like:[pre]%macro gen( from=1, upto= 10, pattern= asdf###asdfg )/ des='pattern generator';
%local word pointer ;
%do pointer = &from %to &upTo ;
%sysfunc( tranwrd( %superq(pattern), ###, &pointer ))
%mend gen ;[/pre]
but beware code offered over the internet you might want to test it on less than 100 datasets
set yourdatasetname end = eof;---->give Your dataset name
if eof then call symput('obs',_n_);--->gives total number of observations
xvar = compress('dsn' || _n_);
call symput (xvar,fieldname);---give the field(area) you should provide
%do i= 1 %to &obs;
%put &&dsn&i; ---->This part is to test if the macro &&dsn&i resolves to correct values!!