- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 03-08-2020 11:05 PM
(663 views)
I am trying to understand how the code runs in the loop to generate the desired outcome:
data Zero_Returns; *calculating number of incidents of zero returns everyday;
set HUF; *and number of zero returns in each of those incidents;
by Date Return notsorted;
if first.Date then Incident_No= 0;
if first.Return then Consecutive_Zero= 1;
else Consecutive_Zero+1;
if last.Return;
if Return= 0;
Incident_No+1;
run;
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Please provide, in the form of a sas DATA step, a sample of your data. And an example of what you expect the output to look like. Your question has too many ambiguities for me to feel I understand it properly.
Help us help you.
--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set
Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets
--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set
Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets
--------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Same logic just not using sub-setting IF. Does this make it better understandable for you?
/**
calculating number of incidents of zero returns everyday
and number of zero returns in each of those incidents
**/
data Zero_Returns;
set HUF;
by Date Return notsorted;
if first.Date then Incident_No= 0;
if first.Return then Consecutive_Zero= 1;
else Consecutive_Zero+1;
if last.Return and Return= 0 then
do;
Incident_No+1;
output;
end;
run;