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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 3 replies
  • 1838 views
  • 2 likes
  • 3 in conversation