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

i want to delete same id. Is there a way? please help me.. thank you..

 

ex)

 

original set                                     fina set

 

id  year  x                                       id  year  x

a  2000  2              -------->             a  2000  2

a  2001  5                                      a   2001 5

b  2000  .                                       c   2000 3

b  2001  5                                      c   2001 3

c  2000  3

c  2001  3

1 ACCEPTED SOLUTION

Accepted Solutions
Shmuel
Garnet | Level 18

It seems you want to delete all rows of same ID YEAR, when IND is missing.

You may try next code:

proc sql
   create table to_del as
   select distinct ID, YEAR
   where IND=.
   from have
order by ID, YEAR; quit; data want; merge have(in=inh) del (in=ind); by ID YEAR; if inh and not ind; run;

View solution in original post

6 REPLIES 6
kiranv_
Rhodochrosite | Level 12

you can remove duplicates by using proc sort. But example you have given is not clear. can you elaborate your example, that is explain in brief, why you want to delete a particular id.

eunsik
Calcite | Level 5

i will analyze by DIFFERENCE-IN-DIFFERENCES (DiD) analysis. and I will use BALANCED DATA SET.  understand me?

 

idYEARTIMEINDTIME x IND idYEARTIMEINDTIME x IND
a200000.230 a200000.230
a200110.220.22 a200110.220.22
b200000.430c200000.550
b20011.. c200113333
c200000.550 d200000.250
c200113333 d200110.40.4
d200000.250      
d200110.40.4      
Shmuel
Garnet | Level 18

It seems you want to delete all rows of same ID YEAR, when IND is missing.

You may try next code:

proc sql
   create table to_del as
   select distinct ID, YEAR
   where IND=.
   from have
order by ID, YEAR; quit; data want; merge have(in=inh) del (in=ind); by ID YEAR; if inh and not ind; run;
eunsik
Calcite | Level 5

thank you so much!!

Ksharp
Super User
data have;
input id $  year  x ;
cards ;
a  2000  2    
a  2001  5                    
b  2000  .                                   
b  2001  5                          
c  2000  3
c  2001  3
;
run;

proc sql;
select *
 from have
  group by id
   haing nmiss(x)=0;
quit;
eunsik
Calcite | Level 5

thank you very much!

It was a great help. thank you.

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
  • 6 replies
  • 1324 views
  • 0 likes
  • 4 in conversation