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;
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.