Below program could be tried, but it is hard to say which is more efficient without test.
data aaa;
input a b c d e f g h;
cards;
1 2 3 4 5 6 7 8
;
run;
data ddd;
set aaa(obs=0 keep=a--d);
p=.;
set aaa(obs=0 keep=e--h);
run;
proc append base=ddd data=aaa force;
run;
If p from other dataset, try to this.
data ddd;
merge aaa (keep=a--d) ccc(keep=p) aaa (keep=e--h);
/*by var if has or wiithout*/
run;