BookmarkSubscribeRSS Feed
ismahero2
Obsidian | Level 7

Hi,

I have a table like this one:

Header 1Header 2Header 3
9994545655654
996gdrgregdg
996dfdgfd
999dfxd
555dfdff
444feffe
333

Now, I want to create a table with only the rows in column "Header 1" where there is a distinct record.  The resulting table should be something like this:

UniqueNumbers
555
444
333

I tried to do a Count but I am having problems selecting Where Count=1.   Any ideas?

3 REPLIES 3
Haikuo
Onyx | Level 15

The following code may get you started:

data have;

infile cards truncover;

input (Header_1 Header_2 Header_3) (:$);

cards;

999 454565 5654

996 gdrgr egdg

996 df dgfd

999 df xd

555 dfd ff

444 fef fe

333

;

proc sql;

  create table want as

    select header_1

  from have

  group by header_1

  having count(*) =1

  ;

quit;

Haikuo

Peter_C
Rhodochrosite | Level 12

A data step solution

PROC SORT DATA= have ;

BY header1;

RUN ;

DATA unique_header1 ;

SET have ;

BY header1 ;

IF FIRST.header1 and LAST.header1;

RUN;

pradeepalankar
Obsidian | Level 7

proc sql;

select header1 as UniqueNumbers from have group by header1 having count(*)=1;

quit;

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
  • 903 views
  • 0 likes
  • 4 in conversation