BookmarkSubscribeRSS Feed
uselessprogress
Calcite | Level 5

I was wondering If there is a way to remove duplicate column values without removing the entire row. This is purely for formatting, and i'd just like to take a step out of my manual workflow.

Basically I'd like to turn this:

LocationDepartments
Location 15400
Location 15401
Location 25402
Location 25403

Into this:

LocationDepartments
Location 15400
5401
Location 25402
5403

Thanks.

3 REPLIES 3
Steelers_In_DC
Barite | Level 11

Here you go:

data have;

infile cards dsd dlm=',';

length location $10.;

input Location $ Departments $;

cards;   

Location 1,5400

Location 1,5401

Location 2,5402

Location 2,5403

;

run;

proc print data=have;id location;by location;

Cynthia_sas
SAS Super FREQ

Hi,

And, PROC REPORT will do this for you too.

cynthia

proc report data=have nowd;

  column location departments;

  define location / order;

  define departments /display;

run;

Jagadishkatam
Amethyst | Level 16

Alternatively you could achieve the same in a datastep by

data want;

set have;

by location;

if not first.location then location='';

run;

Thanks,

Jag

Thanks,
Jag

sas-innovate-2024.png

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.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 825 views
  • 0 likes
  • 4 in conversation