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

@d6k5d3  Here I am re-posting it

 

 

data have;
input (Date      Time     Ask      Bid       Day       Price     Return) ($);
cards;
xxx         xxx       xxx       xxx       Mon     xxx        xxxx
xxx         xxx       xxx       xxx       Mon     xxx        0
xxx         xxx       xxx       xxx       Mon     xxx        0
xxx         xxx       xxx       xxx       Mon     xxx        xxxx
xxx         xxx       xxx       xxx       Mon     xxx        xxxx
xxx         xxx       xxx       xxx       Mon     xxx        0
xxx         xxx       xxx       xxx       Mon     xxx        0
xxx         xxx       xxx       xxx       Mon     xxx        0
xxx         xxx       xxx       xxx       Tue     xxx        0
xxx         xxx       xxx       xxx       Tue     xxx        0
xxx         xxx       xxx       xxx       Tue     xxx        0
xxx         xxx       xxx       xxx       Tue     xxx       xxxx
xxx         xxx       xxx       xxx       Tue     xxx       xxxx
xxx         xxx       xxx       xxx       Tue     xxx        0
xxx         xxx       xxx       xxx       Tue     xxx       xxxx
xxx         xxx       xxx       xxx       Tue     xxx        0
xxx         xxx       xxx       xxx       Wed     xxx        xxxx
xxx         xxx       xxx       xxx       Wed     xxx        0
xxx         xxx       xxx       xxx       Wed     xxx        0
xxx         xxx       xxx       xxx       Wed     xxx        xxxx
xxx         xxx       xxx       xxx       Wed     xxx        xxxx
xxx         xxx       xxx       xxx       Wed     xxx       0
xxx         xxx       xxx       xxx       Wed     xxx       0
xxx         xxx       xxx       xxx       Wed     xxx       0
xxx         xxx       xxx       xxx       Wed     xxx        xxxx
xxx         xxx       xxx       xxx       Wed     xxx        xxxx
xxx         xxx       xxx       xxx       Wed     xxx        xxxx
xxx         xxx       xxx       xxx       Wed     xxx        xxxx
;

data grp;
set have;
by day return notsorted;
if first.day then Incid_of_consec0s =0;
if first.return and return='0' then Incid_of_consec0s+1;
if return='0';
run;

proc sql;
create table want as
select day,Incid_of_consec0s,sum(return='0') as zero_count_in_each_incid
from grp
group by day,Incid_of_consec0s;
quit;

 

 

d6k5d3
Pyrite | Level 9
lost words for saying sorry. I missed it because I was writing the replies, and was trying to clarify. that is why I may have missed it. thank you very much.
novinosrin
Tourmaline | Level 20

No worries 🙂

VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

sorry that I may have not interpreted @d6k5d3 I would like to know for the same day how many returns are 0s statement.

You should have said something about date in your original request so that the your requested was fully stated.

 

novinosrin
Tourmaline | Level 20

data have;
input (Date      Time     Ask      Bid       Day       Price     Return) ($);
cards;
xxx         xxx       xxx       xxx       Mon     xxx        xxxx
xxx         xxx       xxx       xxx       Mon     xxx        xxxx
xxx         xxx       xxx       xxx       Mon     xxx        xxxx
xxx         xxx       xxx       xxx       Tue     xxx        0
xxx         xxx       xxx       xxx       Tue     xxx        0
xxx         xxx       xxx       xxx       Tue     xxx        0
xxx         xxx       xxx       xxx       Tue     xxx        0
xxx         xxx       xxx       xxx       Wed     xxx        xxxx
xxx         xxx       xxx       xxx       Wed     xxx        0
xxx         xxx       xxx       xxx       Wed     xxx        0
;

proc sql;
create table want as
select day,sum(return='0') as zero_retun_count
from have
group by day;
quit;
novinosrin
Tourmaline | Level 20

data have;
input (Date      Time     Ask      Bid       Day       Price     Return) ($);
cards;
xxx         xxx       xxx       xxx       Mon     xxx        xxxx
xxx         xxx       xxx       xxx       Mon     xxx        xxxx
xxx         xxx       xxx       xxx       Mon     xxx        xxxx
xxx         xxx       xxx       xxx       Tue     xxx        0
xxx         xxx       xxx       xxx       Tue     xxx        0
xxx         xxx       xxx       xxx       Tue     xxx        0
xxx         xxx       xxx       xxx       Tue     xxx        0
xxx         xxx       xxx       xxx       Wed     xxx        xxxx
xxx         xxx       xxx       xxx       Wed     xxx        0
xxx         xxx       xxx       xxx       Wed     xxx        0
;
data want;   
     set have;
     by day notsorted;
     if first.day then count=0;
     count +return='0';
     if last.day ;
run;
Astounding
PROC Star

After sifting through many messages, here is what I think you are looking for:

 

data want;

set have;

by date return notsorted;

if first.date then incident_no = 0;

if first.return then consecutive=1;

else consecutive + 1;

if last.return;

if return='0';

incident_no + 1;

run;

d6k5d3
Pyrite | Level 9

Thank you so very much for understanding me! This is what exactly I wanted! Hats off!

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!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 22 replies
  • 2418 views
  • 0 likes
  • 5 in conversation