here I need to create a new dataset for each combination of PersonID And TripID.for eg. for 0001 & 1,there should be differnt dataset and for 0001 & 2, there should be differnt dataset and so on.
List of combination is dynamic and will be stored in a macro as a comma separated list.and combination will also be variant, i.e. it can have any number of columns.
I agree with Patrick, generating many datasets are not a good thing to do (it should be "neater" if you could process the dataset at once without splitting it), but here's an "ugly" (call execute) but simple way of doing it without the complexity of macro coding.
Assuming that Trip is ordered by PersonID and TripID:
by PersonID TripID; /* assume that Trip is ordered */
if first.TripID then do; /* first pair */
_FIRSTOBS=_N_; /* hold the obs num */
_COMBNUM+1; /* count combination number */
if last.TripID then do; /* last pair */
call execute('data COMB'!!cats(put(_COMBNUM,best.))!!
'; set x (firstobs='!!cats(put(_FIRSTOBS,best.))!!' obs = '!!cats(put(_N_,best.))!!'); run;'); /* slice the dataset with call execute call */
Caution, at the end you'll have many COMBx datasets (one per combination).