One way to make sure the variable has the same format is to create it by renaming an existing variable. This code will do what you want (make sure that values of GROUP are valid dataset names). If you only have one record per group then you do not need to do until loop. data _null_; if 0 then set have (keep=group start rename=(start=date)); if _n_=1 then do; declare hash h(ordered:'a',multidata:'y'); h.definekey('date'); h.definedata('group','date'); h.definedone(); end; do until(last.group) ; set have ; by group ; do date= start to end ; rc=h.add(); end ; end; rc=h.output(dataset:group); rc=h.clear(); run;
... View more