BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jozuleta
Obsidian | Level 7

Hi all,

 

I created a table and filtered out the rows which have blanks in columns gvkey , ibitic , isin. Now I want to delete all the duplicate rows which have identical data for column gvkey. In other words... I would like to keep just the rows with unique values for gvkey

My code until now:

PROC SQL;
CREATE TABLE WORK.COMP_DataUS AS
SELECT gvkey , ibtic , isin , sedol
FROM COMP.SECURITY;
RUN;
QUIT;
data WORK.COMP_DataUS;
set COMP_DataUS;
where not missing(gvkey) AND(ibtic) AND(isin);
run; /* Output: 24,936 rows */

this is how my dataset looks like: 

image.png
Basically I would like to have a table without the the blue columns (but for the whole table and not just for these two examples).

Thanks in advance for the support.

 

Best regards

Jorge

1 ACCEPTED SOLUTION

Accepted Solutions
singhsahab
Lapis Lazuli | Level 10

I'm hoping this will work for you !!

 

proc sort data=COMP_DataUS nodup out=want;
by gvkey;
where gvkey is not missing;
run;

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26

UNTESTED CODE

Assumes the data set COMP_DATAUS is sorted by GVKEY

 

proc freq data=comp_dataus;
    table gvkey/noprint out=_a_;
run;

data want;
    merge comp_dataus _a_;
    by gvkey;
    if count>1 then delete;
run;
--
Paige Miller
jozuleta
Obsidian | Level 7
a good other way! Thanks, too!
singhsahab
Lapis Lazuli | Level 10

I'm hoping this will work for you !!

 

proc sort data=COMP_DataUS nodup out=want;
by gvkey;
where gvkey is not missing;
run;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 1802 views
  • 2 likes
  • 3 in conversation