<?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 Re: Call Execute not inserting rows into dataset if noobs=0 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Call-Execute-not-inserting-rows-into-dataset-if-noobs-0/m-p/498466#M132473</link>
    <description>&lt;P&gt;Thank you both for the help.&amp;nbsp; Both solutions worked for me and were very helpful.&lt;/P&gt;</description>
    <pubDate>Mon, 24 Sep 2018 16:26:00 GMT</pubDate>
    <dc:creator>elwayfan446</dc:creator>
    <dc:date>2018-09-24T16:26:00Z</dc:date>
    <item>
      <title>Call Execute not inserting rows into dataset if noobs=0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-Execute-not-inserting-rows-into-dataset-if-noobs-0/m-p/498456#M132467</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can't figure out why this code is not working.&amp;nbsp; I am trying to insert dummy rows into this data set when there are no observations found on it.&amp;nbsp; If I run the proc sql alone, it will insert the rows.&amp;nbsp; However, when I use the call execute if noobs=0, no observations are inserted.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
set msrflow.msrflow_loansfunded_10YR_append;
if nobs=0 then do;
call execute(
'proc sql; 
	insert into msrflow.msrflow_loansfunded_10YR_append 
			(
				PRIMARY_LOAN_KEY 
				,INVESTOR_LOAN_ID 
				,SELLER_LOAN_NUMBER 
				,PNC_LOAN_NUMBER 
				,STATUS 
				,INVESTOR 
				,FUNDING_DATE 
				,NOTE_BALANCE 
				,NOTE_RATE 
				,SERVICE_FEE 
				,LTV 
				,FICO 
				,SRP_RATE 
				,SRP_AMOUNT 
				,PRODUCT 
				,ESCROW_FLAG 
				,PURPOSE 
				,TIMEFRAME 
				,PCT_TOTAL_UPB_PURCHASE 
				,PCT_TOTAL_UPB_REFI 
				,PCT_TOTAL_CNT_ESCROW 
				,PCT_TOTAL_CNT_NONESCROW 
				,WGT_AVG_10YR 
			)
		values (0,"","","","","",.,0,0,0,0,0,0,0,"","","","MTD",0,0,0,0,0)
		values (0,"","","","","",.,0,0,0,0,0,0,0,"","","","YTD",0,0,0,0,0)
		values (0,"","","","","",.,0,0,0,0,0,0,0,"","","","LTD",0,0,0,0,0)
	;
quit;'
);
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 24 Sep 2018 15:58:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-Execute-not-inserting-rows-into-dataset-if-noobs-0/m-p/498456#M132467</guid>
      <dc:creator>elwayfan446</dc:creator>
      <dc:date>2018-09-24T15:58:51Z</dc:date>
    </item>
    <item>
      <title>Re: Call Execute not inserting rows into dataset if noobs=0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-Execute-not-inserting-rows-into-dataset-if-noobs-0/m-p/498459#M132469</link>
      <description>&lt;P&gt;Maxim 2: read the log. You'll find a NOTE that nobs is uninitialized. You forgot the nobs= option in the set statement, and you need to move the set statement after the end and before the run.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Sep 2018 16:06:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-Execute-not-inserting-rows-into-dataset-if-noobs-0/m-p/498459#M132469</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-09-24T16:06:13Z</dc:date>
    </item>
    <item>
      <title>Re: Call Execute not inserting rows into dataset if noobs=0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-Execute-not-inserting-rows-into-dataset-if-noobs-0/m-p/498462#M132471</link>
      <description>&lt;P&gt;When a set statement attempts to read beyond the end of a data set, the data step immediately stops.&amp;nbsp;&amp;nbsp; With zero obs, the first SET provokes that response.&amp;nbsp;&amp;nbsp; There is a way, however, to get the proper nobs:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  if 0 then set msrflow&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;msrflow_loansfunded_10YR_append nobs=nrecs;
  put nrecs=;
  if nrecs=0 then call execute ('....');
  stop;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This works because:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;The is no attempt to read beyond the end of data&amp;nbsp; ("if 0" is always false).&lt;/LI&gt;
&lt;LI&gt;But the "nobs=..." option is evaluated prior to data reading, so NRECS will have a testable value.&lt;/LI&gt;
&lt;LI&gt;The "stop" statement is not necessary, but a good habit for cases like this.&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Mon, 24 Sep 2018 16:08:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-Execute-not-inserting-rows-into-dataset-if-noobs-0/m-p/498462#M132471</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-09-24T16:08:30Z</dc:date>
    </item>
    <item>
      <title>Re: Call Execute not inserting rows into dataset if noobs=0</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-Execute-not-inserting-rows-into-dataset-if-noobs-0/m-p/498466#M132473</link>
      <description>&lt;P&gt;Thank you both for the help.&amp;nbsp; Both solutions worked for me and were very helpful.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Sep 2018 16:26:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-Execute-not-inserting-rows-into-dataset-if-noobs-0/m-p/498466#M132473</guid>
      <dc:creator>elwayfan446</dc:creator>
      <dc:date>2018-09-24T16:26:00Z</dc:date>
    </item>
  </channel>
</rss>

