<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic SAS LOOP does not finish processing (WORK WITH WRDS) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-LOOP-does-not-finish-processing-WORK-WITH-WRDS/m-p/720185#M223070</link>
    <description>&lt;P&gt;Hi there!&lt;/P&gt;&lt;P&gt;I am a PhD student working with SAS and WRDS cloud.&lt;/P&gt;&lt;P&gt;I have a loop over the years 1990-2018 that stops processing without any availible log. Just gets stuck and that's it.&lt;/P&gt;&lt;P&gt;I checked the loop over shorter periods of time and it works just fine. For example, I checked for the years 1990-1992 and it works.&lt;/P&gt;&lt;P&gt;What could be the issue?&lt;/P&gt;&lt;P&gt;I thought maybe the problem was somehow due to session timeout? Any Ideas?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 18 Feb 2021 14:18:57 GMT</pubDate>
    <dc:creator>margalits1</dc:creator>
    <dc:date>2021-02-18T14:18:57Z</dc:date>
    <item>
      <title>SAS LOOP does not finish processing (WORK WITH WRDS)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-LOOP-does-not-finish-processing-WORK-WITH-WRDS/m-p/720185#M223070</link>
      <description>&lt;P&gt;Hi there!&lt;/P&gt;&lt;P&gt;I am a PhD student working with SAS and WRDS cloud.&lt;/P&gt;&lt;P&gt;I have a loop over the years 1990-2018 that stops processing without any availible log. Just gets stuck and that's it.&lt;/P&gt;&lt;P&gt;I checked the loop over shorter periods of time and it works just fine. For example, I checked for the years 1990-1992 and it works.&lt;/P&gt;&lt;P&gt;What could be the issue?&lt;/P&gt;&lt;P&gt;I thought maybe the problem was somehow due to session timeout? Any Ideas?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Feb 2021 14:18:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-LOOP-does-not-finish-processing-WORK-WITH-WRDS/m-p/720185#M223070</guid>
      <dc:creator>margalits1</dc:creator>
      <dc:date>2021-02-18T14:18:57Z</dc:date>
    </item>
    <item>
      <title>Re: SAS LOOP does not finish processing (WORK WITH WRDS)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-LOOP-does-not-finish-processing-WORK-WITH-WRDS/m-p/720215#M223089</link>
      <description>&lt;P&gt;Please post your code. You may have an issue where data keeps growing with longer loops, and/or processing time grows exponentially.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Feb 2021 15:33:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-LOOP-does-not-finish-processing-WORK-WITH-WRDS/m-p/720215#M223089</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-02-18T15:33:47Z</dc:date>
    </item>
    <item>
      <title>Re: SAS LOOP does not finish processing (WORK WITH WRDS)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-LOOP-does-not-finish-processing-WORK-WITH-WRDS/m-p/720225#M223096</link>
      <description>The relevant macro is calc year:&lt;BR /&gt;%macro calc_year(year);&lt;BR /&gt;/* Run signs regression for a single year */&lt;BR /&gt;%combine_sic_codes;&lt;BR /&gt;%choose_years(&amp;amp;year);&lt;BR /&gt;%at_least_two_firms;&lt;BR /&gt;%consecutive_24_quarters;&lt;BR /&gt;%rdq_min_max;&lt;BR /&gt;%add_earning_surprise;&lt;BR /&gt;%the_y_side(&amp;amp;year);&lt;BR /&gt;%combine_x_and_y(&amp;amp;year);&lt;BR /&gt;&lt;BR /&gt;%if %sysfunc(exist(all_years_signs)) %then %do;&lt;BR /&gt;proc sql;&lt;BR /&gt;insert into all_years_signs&lt;BR /&gt;select * from b;&lt;BR /&gt;quit;&lt;BR /&gt;run;&lt;BR /&gt;%end;&lt;BR /&gt;%else %do;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table all_years_signs as&lt;BR /&gt;select * from b;&lt;BR /&gt;quit;&lt;BR /&gt;run;&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;BR /&gt;&lt;BR /&gt;%macro program;&lt;BR /&gt;%local year;&lt;BR /&gt;%do year=1990 %to 2018;&lt;BR /&gt;%calc_year(&amp;amp;year);&lt;BR /&gt;%end;&lt;BR /&gt;&lt;BR /&gt;%save_data_file_to_temp(all_years_signs);&lt;BR /&gt;%export_data(all_years_signs)&lt;BR /&gt;%mend;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;But here is the full code:&lt;BR /&gt;/*Calculating the sign*/&lt;BR /&gt;&lt;BR /&gt;%macro wrds_connect;&lt;BR /&gt;%let wrds=wrds-cloud.wharton.upenn.edu 4016;&lt;BR /&gt;options comamid=TCP remote=WRDS;&lt;BR /&gt;signon username=_prompt_;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;rsubmit;&lt;BR /&gt;libname crsp '/wrds/crsp/sasdata/a_stock';&lt;BR /&gt;libname temp '/scratch/tau/margalit';&lt;BR /&gt;libname cc '/wrds/crsp/sasdata/a_ccm';&lt;BR /&gt;libname index '/wrds/crsp/sasdata/a_indexes';&lt;BR /&gt;libname comp '/wrds/comp/sasdata/nam';&lt;BR /&gt;libname ix '/wrds/crsp/sasdata/ix';&lt;BR /&gt;libname home '/home/tau/margalit';&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;%mend;&lt;BR /&gt;%wrds_connect;&lt;BR /&gt;&lt;BR /&gt;%macro combine_sic_codes;&lt;BR /&gt;data sic_codes; set home.sic_codes_q;&lt;BR /&gt;keep gvkey datadate sic;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc sort data=sic_codes nodupkey;&lt;BR /&gt;by gvkey datadate;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;/*Combine with SIC Codes. Not appear in cloud*/&lt;BR /&gt;data comp1; set comp.fundq;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc sort data=comp1 nodupkey;&lt;BR /&gt;by gvkey datadate;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;data comp2;&lt;BR /&gt;merge comp1 sic_codes;&lt;BR /&gt;by gvkey datadate;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;%mend;&lt;BR /&gt;&lt;BR /&gt;%macro choose_years(year_sign);&lt;BR /&gt;%local / readonly start_year=%eval(&amp;amp;year_sign-6);&lt;BR /&gt;%local / readonly end_year=%eval(&amp;amp;year_sign-1);&lt;BR /&gt;%local / readonly start_date="01jan&amp;amp;start_year"d;&lt;BR /&gt;%local / readonly end_date="31dec&amp;amp;end_year"d;&lt;BR /&gt;&lt;BR /&gt;data comp3; set comp2;&lt;BR /&gt;if datadate&amp;gt;=&amp;amp;start_date and datadate&amp;lt;=&amp;amp;end_date;&lt;BR /&gt;if INDFMT='INDL' and DATAFMT='STD' and POPsrc='D' and CONSOL='C';&lt;BR /&gt;if finalq ne "Y" or iid ne "01" then delete;&lt;BR /&gt;if fyr~=12 then delete;&lt;BR /&gt;if rdq=. then delete;&lt;BR /&gt;keep datadate sic fyr rdq gvkey FYEARQ FQTR DATACQTR cusip ceqq&lt;BR /&gt;XRDQ REVTQ MKVALTQ OANCFY NIY ATQ SALEQ IBQ;&lt;BR /&gt;run;&lt;BR /&gt;%mend;&lt;BR /&gt;&lt;BR /&gt;%macro at_least_two_firms;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table sic_helper as&lt;BR /&gt;select sic,datadate, count(distinct gvkey) as sic_count&lt;BR /&gt;from comp3&lt;BR /&gt;group by sic, datadate&lt;BR /&gt;having sic_count&amp;gt;=2;&lt;BR /&gt;quit;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;/*Keep only relevant sic codes*/&lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table comp as&lt;BR /&gt;select * from comp3 c&lt;BR /&gt;where exists(&lt;BR /&gt;select * from sic_helper sh&lt;BR /&gt;where sh.sic = c.sic and sh.datadate = c.datadate);&lt;BR /&gt;quit;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;%mend;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;%macro keep_n_consecutive_obs_for_var(num_obs, var_name, out_name);&lt;BR /&gt;proc sort data=comp;&lt;BR /&gt;by gvkey &amp;amp;var_name;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc means data=comp N noprint;&lt;BR /&gt;var &amp;amp;var_name;&lt;BR /&gt;by gvkey;&lt;BR /&gt;output out=&amp;amp;out_name N=NumFirmObs;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;data &amp;amp;out_name; set &amp;amp;out_name;&lt;BR /&gt;if NumFirmObs=&amp;amp;num_obs;&lt;BR /&gt;run;&lt;BR /&gt;%mend;&lt;BR /&gt;&lt;BR /&gt;%macro consecutive_24_quarters;&lt;BR /&gt;/*keep only firms with 24 consequative quarters*/&lt;BR /&gt;%keep_n_consecutive_obs_for_var(24, rdq, Z1);&lt;BR /&gt;%keep_n_consecutive_obs_for_var(24, SALEQ, Z2);&lt;BR /&gt;%keep_n_consecutive_obs_for_var(24, IBQ, Z3); /*IBQ - income before extraordinary items*/&lt;BR /&gt;&lt;BR /&gt;/*Select only firms with 24 consequtive obs*/&lt;BR /&gt;proc sql;&lt;BR /&gt;create table reg_data as&lt;BR /&gt;select * from comp&lt;BR /&gt;where&lt;BR /&gt;exists(select * from z1 where z1.gvkey = comp.gvkey) and&lt;BR /&gt;exists(select * from z2 where z2.gvkey = comp.gvkey) and&lt;BR /&gt;exists(select * from z3 where z3.gvkey = comp.gvkey);&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;%mend;&lt;BR /&gt;&lt;BR /&gt;%macro save_data_file_to_temp(data_name);&lt;BR /&gt;data temp.&amp;amp;data_name; set &amp;amp;data_name;&lt;BR /&gt;run;&lt;BR /&gt;%mend;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;%macro export_data(data_name);&lt;BR /&gt;proc export data=&amp;amp;data_name&lt;BR /&gt;outfile='/scratch/tau/margalit/&amp;amp;data_name.csv'&lt;BR /&gt;dbms=csv&lt;BR /&gt;replace;&lt;BR /&gt;run;&lt;BR /&gt;%mend;&lt;BR /&gt;&lt;BR /&gt;%macro rdq_min_max;&lt;BR /&gt;/*calcuate the report period - min and max date*/&lt;BR /&gt;proc sort data=reg_data;&lt;BR /&gt;by sic datadate;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;/*find minumin and maximum rdq date within SIC CODE*/&lt;BR /&gt;proc sql;&lt;BR /&gt;create table rdq_min_max as&lt;BR /&gt;select sic, datadate, min(rdq) as min, max(rdq) as max&lt;BR /&gt;from reg_data&lt;BR /&gt;group by sic, datadate;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;/*Format Dates*/&lt;BR /&gt;proc datasets lib=temp nolist;&lt;BR /&gt;modify rdq_min_max;&lt;BR /&gt;format max date9.;&lt;BR /&gt;format min date9.;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;%save_data_file_to_temp(rdq_min_max);&lt;BR /&gt;%mend;&lt;BR /&gt;&lt;BR /&gt;%macro add_earning_surprise;&lt;BR /&gt;/*add previous quarter*/&lt;BR /&gt;proc sql;&lt;BR /&gt;create table reg_data1 as&lt;BR /&gt;select reg_data.*, b.ibq as last_ibq&lt;BR /&gt;from reg_data&lt;BR /&gt;join reg_data as b&lt;BR /&gt;on reg_data.gvkey = b.gvkey and&lt;BR /&gt;reg_data.fqtr = b.fqtr and&lt;BR /&gt;reg_data.fyearq = b.fyearq + 1;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;/*add agg ibq*/&lt;BR /&gt;proc sql;&lt;BR /&gt;create table agg as&lt;BR /&gt;select sic, datadate,&lt;BR /&gt;sum(last_ibq) as last_q_sum,&lt;BR /&gt;sum(ibq) as sum_q,&lt;BR /&gt;sum(ATQ) as sum_agg_atq&lt;BR /&gt;from reg_data1&lt;BR /&gt;group by sic, datadate;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;/*Combine with RegData table&lt;BR /&gt;reg_data: sum_all_others_without i, earning surprise firm&lt;BR /&gt;*/&lt;BR /&gt;proc sql;&lt;BR /&gt;create table reg_data3 as&lt;BR /&gt;select reg_data1.*,agg.last_q_sum, agg.sum_q,&lt;BR /&gt;/*earnings aggragate other firms*/&lt;BR /&gt;agg.sum_q - reg_data1.ibq as agg_ibq_without_i,&lt;BR /&gt;agg.last_q_sum - reg_data1.last_ibq as last_agg_ibq_without_i,&lt;BR /&gt;agg.sum_agg_atq - reg_data1.atq as agg_sum_atq_without_i,&lt;BR /&gt;(reg_data1.ibq - reg_data1.last_ibq) / reg_data1.atq as ear_surprise_i&lt;BR /&gt;from reg_data1&lt;BR /&gt;join agg&lt;BR /&gt;on reg_data1.sic = agg.sic and&lt;BR /&gt;reg_data1.datadate = agg.datadate;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;data reg_data3; set reg_data3;&lt;BR /&gt;earn_surprise_other=(agg_ibq_without_i-last_agg_ibq_without_i)/agg_sum_atq_without_i;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;data reg_data3; set reg_data3;&lt;BR /&gt;if earn_surprise_other=. then delete;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;%save_data_file_to_temp(reg_data3);&lt;BR /&gt;%mend;&lt;BR /&gt;&lt;BR /&gt;%macro the_y_side(year_sign);&lt;BR /&gt;/*TODO: Split to separate Macros!!!*/&lt;BR /&gt;/*Create table with Comp and Compustat data*/&lt;BR /&gt;proc sql;&lt;BR /&gt;create table comp as&lt;BR /&gt;select a.*, b.lpermno as permno&lt;BR /&gt;from temp.reg_data3 as a, cc.ccmxpf_linktable as b&lt;BR /&gt;where&lt;BR /&gt;a.gvkey = b.gvkey and&lt;BR /&gt;b.linkprim in ('P', 'C') and&lt;BR /&gt;b.LINKTYPE in ('LU', 'LC') and&lt;BR /&gt;(a.datadate &amp;gt;= b.LINKDT or missing(b.LINKENDDT)) and&lt;BR /&gt;(a.datadate &amp;lt;= b.LINKENDDT or missing(b.LINKENDDT))&lt;BR /&gt;order by gvkey, datadate;&lt;BR /&gt;quit;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;/*Until this part- VVVV*/&lt;BR /&gt;&lt;BR /&gt;/*Create table with Comp and Compustat data with daily stock data XX to XX days around quarterly earning ann*/&lt;BR /&gt;%local / readonly dsf_start_year=%eval(&amp;amp;year_sign-5);&lt;BR /&gt;%local / readonly dsf_end_year=&amp;amp;year_sign;&lt;BR /&gt;%local / readonly dsf_start_date="01jan&amp;amp;dsf_start_year"d;&lt;BR /&gt;%local / readonly dsf_end_date="31mar&amp;amp;dsf_end_year"d;&lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table temp.stocks as&lt;BR /&gt;select comp.gvkey, dsf.ret, dsf.date, dsf.shrout, dsf.prc, dsf.cusip&lt;BR /&gt;from crspa.dsf, comp&lt;BR /&gt;where&lt;BR /&gt;dsf.permno = comp.permno and&lt;BR /&gt;dsf.date &amp;gt;= &amp;amp;dsf_start_date and&lt;BR /&gt;dsf.date &amp;lt;= &amp;amp;dsf_end_date;&lt;BR /&gt;quit;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;/*Not sure if to add*/&lt;BR /&gt;data temp.stocks; set temp.stocks;&lt;BR /&gt;proc sort nodup;&lt;BR /&gt;by gvkey date;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;/*compute returns*/&lt;BR /&gt;proc sql;&lt;BR /&gt;create table reg_min_max as&lt;BR /&gt;select rd.*, mm.min, mm.max&lt;BR /&gt;from comp rd&lt;BR /&gt;join temp.rdq_min_max mm&lt;BR /&gt;on rd.sic = mm.sic and&lt;BR /&gt;rd.datadate = mm.datadate;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;/*reg_min_max VVV*/&lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table reg_stocks as&lt;BR /&gt;select s.*, rmm.sic, rmm.datadate, rmm.min, rmm.max&lt;BR /&gt;from temp.stocks s&lt;BR /&gt;join reg_min_max rmm&lt;BR /&gt;on s.gvkey = rmm.gvkey and&lt;BR /&gt;s.date between rmm.min and rmm.max;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;/*Not sure if to add*/&lt;BR /&gt;data reg_stocks; set reg_stocks;&lt;BR /&gt;proc sort nodup;&lt;BR /&gt;by gvkey date;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table reg_stocks_log as&lt;BR /&gt;select rs.*, LOG(rs.ret + 1) as lnret&lt;BR /&gt;from reg_stocks rs;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table returns as&lt;BR /&gt;select rsl.gvkey, rsl.sic, rsl.datadate,&lt;BR /&gt;exp(sum(rsl.lnret)) - 1 as ret_window&lt;BR /&gt;from reg_stocks_log rsl&lt;BR /&gt;group by rsl.gvkey, rsl.sic, rsl.datadate;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;/*%save_data_file_to_temp(returns);*/&lt;BR /&gt;%mend;&lt;BR /&gt;&lt;BR /&gt;%macro combine_x_and_y(year_sign);&lt;BR /&gt;proc sql;&lt;BR /&gt;create table x_y as&lt;BR /&gt;select rd3.*, r.ret_window&lt;BR /&gt;from returns r&lt;BR /&gt;join reg_data3 rd3&lt;BR /&gt;on r.gvkey = rd3.gvkey and&lt;BR /&gt;r.datadate = rd3.datadate;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc sort data=x_y;&lt;BR /&gt;by sic gvkey datadate;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;%save_data_file_to_temp(x_y);&lt;BR /&gt;&lt;BR /&gt;proc panel data = x_y outest=b noprint;&lt;BR /&gt;id gvkey datadate;&lt;BR /&gt;model ret_window = ear_surprise_i earn_surprise_other / fixone;&lt;BR /&gt;by sic;&lt;BR /&gt;quit;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;data b; set b;&lt;BR /&gt;year = &amp;amp;year_sign;&lt;BR /&gt;run;&lt;BR /&gt;%mend;&lt;BR /&gt;&lt;BR /&gt;%macro calc_year(year);&lt;BR /&gt;/* Run signs regression for a single year */&lt;BR /&gt;%combine_sic_codes;&lt;BR /&gt;%choose_years(&amp;amp;year);&lt;BR /&gt;%at_least_two_firms;&lt;BR /&gt;%consecutive_24_quarters;&lt;BR /&gt;%rdq_min_max;&lt;BR /&gt;%add_earning_surprise;&lt;BR /&gt;%the_y_side(&amp;amp;year);&lt;BR /&gt;%combine_x_and_y(&amp;amp;year);&lt;BR /&gt;&lt;BR /&gt;%if %sysfunc(exist(all_years_signs)) %then %do;&lt;BR /&gt;proc sql;&lt;BR /&gt;insert into all_years_signs&lt;BR /&gt;select * from b;&lt;BR /&gt;quit;&lt;BR /&gt;run;&lt;BR /&gt;%end;&lt;BR /&gt;%else %do;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table all_years_signs as&lt;BR /&gt;select * from b;&lt;BR /&gt;quit;&lt;BR /&gt;run;&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;BR /&gt;&lt;BR /&gt;%macro program;&lt;BR /&gt;%local year;&lt;BR /&gt;%do year=1990 %to 2018;&lt;BR /&gt;%calc_year(&amp;amp;year);&lt;BR /&gt;%end;&lt;BR /&gt;&lt;BR /&gt;%save_data_file_to_temp(all_years_signs);&lt;BR /&gt;%export_data(all_years_signs)&lt;BR /&gt;%mend;&lt;BR /&gt;&lt;BR /&gt;%program;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 18 Feb 2021 15:45:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-LOOP-does-not-finish-processing-WORK-WITH-WRDS/m-p/720225#M223096</guid>
      <dc:creator>margalits1</dc:creator>
      <dc:date>2021-02-18T15:45:03Z</dc:date>
    </item>
    <item>
      <title>Re: SAS LOOP does not finish processing (WORK WITH WRDS)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-LOOP-does-not-finish-processing-WORK-WITH-WRDS/m-p/720231#M223100</link>
      <description>&lt;P&gt;Instead of&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if %sysfunc(exist(all_years_signs)) %then %do;
proc sql;
insert into all_years_signs
select * from b;
quit;
run;
%end;
%else %do;
proc sql;
create table all_years_signs as
select * from b;
quit;
run;
%end;
%mend;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;do this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc append
  base=all_years_signs
  data=b
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Instead of&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if datadate&amp;gt;=&amp;amp;start_date and datadate&amp;lt;=&amp;amp;end_date;
if INDFMT='INDL' and DATAFMT='STD' and POPsrc='D' and CONSOL='C';
if finalq ne "Y" or iid ne "01" then delete;
if fyr~=12 then delete;
if rdq=. then delete;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;do&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where
  datadate&amp;gt;=&amp;amp;start_date and datadate&amp;lt;=&amp;amp;end_date and
  INDFMT='INDL' and DATAFMT='STD' and POPsrc='D' and CONSOL='C' and not(
    finalq ne "Y" or iid ne "01" or fyr~=12 or rdq=.
  )
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;WHERE conditions outperform subsetting IFs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It might also be that your code runs so long it exceeds a limit that drops an inactive network connection.&lt;/P&gt;
&lt;P&gt;Doesn't WRDS use SAS/CONNECT?&lt;/P&gt;</description>
      <pubDate>Thu, 18 Feb 2021 16:00:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-LOOP-does-not-finish-processing-WORK-WITH-WRDS/m-p/720231#M223100</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-02-18T16:00:49Z</dc:date>
    </item>
    <item>
      <title>Re: SAS LOOP does not finish processing (WORK WITH WRDS)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-LOOP-does-not-finish-processing-WORK-WITH-WRDS/m-p/720713#M223277</link>
      <description>Hello Kurt&lt;BR /&gt;thank you I will try your suggested chnges and update whether it works &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;Yes WRDS uses SAS/connect:&lt;BR /&gt;I have it also in a macro:&lt;BR /&gt;%macro wrds_connect;&lt;BR /&gt;%let wrds=wrds-cloud.wharton.upenn.edu 4016;&lt;BR /&gt;options comamid=TCP remote=WRDS;&lt;BR /&gt;signon username=_prompt_;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;rsubmit;&lt;BR /&gt;libname crsp '/wrds/crsp/sasdata/a_stock';&lt;BR /&gt;libname temp '/scratch/tau/margalit';&lt;BR /&gt;libname cc '/wrds/crsp/sasdata/a_ccm';&lt;BR /&gt;libname index '/wrds/crsp/sasdata/a_indexes';&lt;BR /&gt;libname comp '/wrds/comp/sasdata/nam';&lt;BR /&gt;libname ix '/wrds/crsp/sasdata/ix';&lt;BR /&gt;libname home '/home/tau/margalit';&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;%mend;&lt;BR /&gt;%wrds_connect;&lt;BR /&gt;&lt;BR /&gt;Thanks again ! will update results</description>
      <pubDate>Sun, 21 Feb 2021 06:15:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-LOOP-does-not-finish-processing-WORK-WITH-WRDS/m-p/720713#M223277</guid>
      <dc:creator>margalits1</dc:creator>
      <dc:date>2021-02-21T06:15:38Z</dc:date>
    </item>
    <item>
      <title>Re: SAS LOOP does not finish processing (WORK WITH WRDS)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-LOOP-does-not-finish-processing-WORK-WITH-WRDS/m-p/720961#M223372</link>
      <description>&lt;P&gt;Hello Kurt,&lt;/P&gt;&lt;P&gt;I wanted to update you that I added the changes and the code worked.&lt;/P&gt;&lt;P&gt;Thank you very much for your help!&lt;/P&gt;&lt;P&gt;Really appricieate it.&lt;/P&gt;&lt;P&gt;Margalit&lt;/P&gt;</description>
      <pubDate>Mon, 22 Feb 2021 16:52:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-LOOP-does-not-finish-processing-WORK-WITH-WRDS/m-p/720961#M223372</guid>
      <dc:creator>margalits1</dc:creator>
      <dc:date>2021-02-22T16:52:41Z</dc:date>
    </item>
  </channel>
</rss>

