Hello I am running the following code to get the table I want. I have attached the table I "have" (sample records) and the table I "want" with this message. proc sql;
create table cohort as select *
from source.table
where term='201602' and
rsts_date<='16OCT2015:02:00:00'dt and
activity_date<='16OCT2015:02:00:00'dt;
quit;
data cohort1;
set cohort;
length code$ 25.;
code=id||crn;
proc sort; by code descending seq_number;
data cohort2;
set cohort1;
by code;
if first.code;
if rsts_code not in ('RE','RW','RC','AU','CT','RX') then delete;
if error_flag='F' then delete;
if substr(message,1,14)='Record deleted' then delete;
run;
proc sql;
create table cohort3 as select distinct term,date,sum(credits) as credits format=comma8.
from cohort2
group by date;
quit;
proc datasets nolist;
append base=final data=cohort3 force;
quit; To get the 'want' table that I have attached, i run the above script manually each time with successive dates. My question: Can I create a new script using the logic above to automatically repeat the code enough times to reach the end of the date range. So currently, the date range I want is from Oct 15 2015 to Feb 15 2016. So I need to run this script for each date starting from Oct 15 2016, then Oct 16 2016, then Oct 17 2016...up to Feb 15 2016. In my "want" table, I have only shown two dates that I ran manually as an example. I want this to run repeatedly grouping the data by date. There are 124 days between oct 15 2015 and feb 15 2016 so I would need a table with 124 rows. Hope I am making sense. Thanks in advance ananda
... View more