BookmarkSubscribeRSS Feed
ernie86
Calcite | Level 5

Here is what the dataset looks like this right now

NAMEA1A2A3P1P2P3
MIKE1.21.681.62.96.73.0
NANCY2.36.31.97.63.67.1
JEN2.12.22.46.27.13.4

I want the output to look like this

NAMEA1A2A3P1P2P3
MIKE1.21.681.6...
MIKE...2.96.73.0
NANCY2.36.31.9...
NANCY...7.63.67.1
JEN2.12.22.4...
JEN...6.27.13.4

Can someone please help on how to code in SAS Enterprise Guide? Any hint is helpful.

4 REPLIES 4
Haikuo
Onyx | Level 15

data want;

set have have;

call missing(of p:);

output;

set have;

call missing(of a:);

output;

run;

HarryLiu
Obsidian | Level 7

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;

Astounding
PROC Star

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;

Ksharp
Super User

Code: Program

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;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 2063 views
  • 2 likes
  • 5 in conversation