BookmarkSubscribeRSS Feed
namrata
Fluorite | Level 6

I have created a dummy 0/1 against years prior to an event and after an event.

I want to delete firms that have  dummy=0 less than 2 times and dummy=1 less than 3 times.

Is it possible to combine both the conditions?

The code below is wrong but what should be be corrected below?

proc sql;

create table want as

select dummy,count(dummy=0) as count1

select dummy,count(dummy=1) as count2

  from have

   group by gvkey having calculated count1 gt 2 & count2 gt 3 ;

quit;

1 REPLY 1
Linlin
Lapis Lazuli | Level 10

try:

data have;

  input firm dummy;

  cards;

  1 0

  1 1

  1 0

  1 0

  1 1

  1 1

  2 0

  2 1

  3 0

  3 0

  3 0

  ;

proc sql;

  create table  want as

    select firm

           ,sum(dummy=0) as  c1

          ,sum(dummy=1) as c2

   from have

     group by firm

  having c1>1 and c2>2;

quit;

proc print;run;

Linlin

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
  • 1 reply
  • 597 views
  • 0 likes
  • 2 in conversation