Here is what the dataset looks like this right now
NAME | A1 | A2 | A3 | P1 | P2 | P3 |
---|---|---|---|---|---|---|
MIKE | 1.2 | 1.68 | 1.6 | 2.9 | 6.7 | 3.0 |
NANCY | 2.3 | 6.3 | 1.9 | 7.6 | 3.6 | 7.1 |
JEN | 2.1 | 2.2 | 2.4 | 6.2 | 7.1 | 3.4 |
I want the output to look like this
NAME | A1 | A2 | A3 | P1 | P2 | P3 |
---|---|---|---|---|---|---|
MIKE | 1.2 | 1.68 | 1.6 | . | . | . |
MIKE | . | . | . | 2.9 | 6.7 | 3.0 |
NANCY | 2.3 | 6.3 | 1.9 | . | . | . |
NANCY | . | . | . | 7.6 | 3.6 | 7.1 |
JEN | 2.1 | 2.2 | 2.4 | . | . | . |
JEN | . | . | . | 6.2 | 7.1 | 3.4 |
Can someone please help on how to code in SAS Enterprise Guide? Any hint is helpful.
data want;
set have have;
call missing(of p:);
output;
set have;
call missing(of a:);
output;
run;
You can split the data set into two subset and then combine them.
Here is coding:
data a (keep= name a1-a3) p (keep=name p1-p3);
set old;
run;
data want;
set a p;
run;
proc sort data=want;
by name;
run;
Another variation on the theme keeps the names in their original order:
data just_p ;
set have;
call missing(of a:);
run;
data want;
set have;
call missing(of p:);
output;
set just_p;
output;
run;
data have;
infile cards expandtabs truncover;
input name $ a1-a3 p1-p3;
cards;
MIKE 1.2 1.68 1.6 2.9 6.7 3.0
NANCY 2.3 6.3 1.9 7.6 3.6 7.1
JEN 2.1 2.2 2.4 6.2 7.1 3.4
;
run;
data want;
set have;
array x{3} _temporary_;
array _p{*} p1-p3;
do i=1 to dim(x);
x{i}=_p{i};
end;
call missing(of p:);output;
do i=1 to dim(x);
_p{i}=x{i};
end;
call missing(of a:);output;
drop i;
run;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.