<?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: PROC EXPORT DATA to OUTFILE Giving Error in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-DATA-to-OUTFILE-Giving-Error/m-p/707715#M217331</link>
    <description>&lt;P&gt;Such minuscule log snippets do not help in locating the problem. Please post complete code, and complete logs for steps that fail.&lt;/P&gt;</description>
    <pubDate>Tue, 22 Dec 2020 16:51:04 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2020-12-22T16:51:04Z</dc:date>
    <item>
      <title>PROC EXPORT DATA to OUTFILE Giving Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-DATA-to-OUTFILE-Giving-Error/m-p/707559#M217258</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;While researching a way to export records from a dataset to excel workbooks based on Sequence number I stumbled across this old topic:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Procedures/Problem-with-PROC-EXPORT/td-p/88349" target="_blank"&gt;https://communities.sas.com/t5/SAS-Procedures/Problem-with-PROC-EXPORT/td-p/88349&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am having trouble with the solution because I am getting the error "Server Name is invalid or missing."&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the code I am running:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc sort data=sellersheet out=loop (keep=SeqNo seller_name)nodupkey;
by SeqNo;
run;

data _null_;
  set loop;
  call execute(cats('proc export data=sellersheet (where=(SeqNo="',SeqNo,'")) outfile="/sae/aal_labapm/01/mortgage/msracq/DATA WAREHOUSE/DWACQ/REPORT FILES/MSR0028/&amp;amp;filedate.',seller_name,'.xlsx";sheet="','LOANLIST','"; run;'));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The error I am receiving during the call execute step:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="elwayfan446_0-1608582211779.png" style="width: 711px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/52945i4E0239F2FDB0C3D9/image-dimensions/711x171?v=v2" width="711" height="171" role="button" title="elwayfan446_0-1608582211779.png" alt="elwayfan446_0-1608582211779.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The file path is on a server and not on a network or PC.&amp;nbsp; I can't figure out if it has something to do with that or not.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Dec 2020 20:26:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-DATA-to-OUTFILE-Giving-Error/m-p/707559#M217258</guid>
      <dc:creator>elwayfan446</dc:creator>
      <dc:date>2020-12-21T20:26:39Z</dc:date>
    </item>
    <item>
      <title>Re: PROC EXPORT DATA to OUTFILE Giving Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-DATA-to-OUTFILE-Giving-Error/m-p/707564#M217261</link>
      <description>&lt;P&gt;You missed to add the DBMS=XLSX option to the PROC EXPORT statement.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Dec 2020 21:11:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-DATA-to-OUTFILE-Giving-Error/m-p/707564#M217261</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-12-21T21:11:27Z</dc:date>
    </item>
    <item>
      <title>Re: PROC EXPORT DATA to OUTFILE Giving Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-DATA-to-OUTFILE-Giving-Error/m-p/707682#M217314</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt; thank you for your reply.&amp;nbsp;&amp;nbsp; I had tried that yesterday and was getting an error.&amp;nbsp; I had moved on from that but it was exactly what was wrong.&amp;nbsp; I believe I had it in the wrong spot of the syntax.&amp;nbsp; Thank you!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Following up... is there a way to exclude the variables in my proc export that I am using to query the records?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to drop SeqNo and seller_name from the exported file but since I am using them for the query, it throws an error if I try to use the DROP= statement&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;(where=(SeqNo=',SeqNo,'))&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;outfile="/sae/aal_labapm/01/mortgage/msracq/DATA WAREHOUSE/DWACQ/REPORT FILES/MSR0028/&amp;amp;filedate._',seller_name,'.xlsx"&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Dec 2020 15:18:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-DATA-to-OUTFILE-Giving-Error/m-p/707682#M217314</guid>
      <dc:creator>elwayfan446</dc:creator>
      <dc:date>2020-12-22T15:18:50Z</dc:date>
    </item>
    <item>
      <title>Re: PROC EXPORT DATA to OUTFILE Giving Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-DATA-to-OUTFILE-Giving-Error/m-p/707715#M217331</link>
      <description>&lt;P&gt;Such minuscule log snippets do not help in locating the problem. Please post complete code, and complete logs for steps that fail.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Dec 2020 16:51:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-DATA-to-OUTFILE-Giving-Error/m-p/707715#M217331</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-12-22T16:51:04Z</dc:date>
    </item>
    <item>
      <title>Re: PROC EXPORT DATA to OUTFILE Giving Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-DATA-to-OUTFILE-Giving-Error/m-p/707716#M217332</link>
      <description>&lt;P&gt;Make a copy of that data and export that.&amp;nbsp; Instead of just generating the PROC EXPORT code&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc export data=ORIGINAL(where=(seqno='xxx')) ....&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;generate code like this instead:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data for_export ;
  set ORIGINAL;
  where seqno='xxx';
&amp;nbsp;&amp;nbsp;drop&amp;nbsp;seqno;
run;
proc&amp;nbsp;export&amp;nbsp;data=for_export&amp;nbsp;....&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Dec 2020 16:57:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-DATA-to-OUTFILE-Giving-Error/m-p/707716#M217332</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-12-22T16:57:27Z</dc:date>
    </item>
    <item>
      <title>Re: PROC EXPORT DATA to OUTFILE Giving Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-DATA-to-OUTFILE-Giving-Error/m-p/707723#M217335</link>
      <description>&lt;P&gt;Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt; .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think I still have the same problem even if I do that.&amp;nbsp; Here is all of the code I am running:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am looping through each seller to get the SeqNo that was assigned to each in the dataset sellersheet:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=sellersheet out=loop (keep=SeqNo seller_name)nodupkey;
by SeqNo;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In my CALL EXECUTE() I have to export a new excel file for every SeqNo so I am comparing the SeqNo in the loop dataset to the SeqNo in the sellersheet dataset so all of the info from the sellersheet dataset gets exported into the file for its SeqNo.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set loop;
  call execute(cats('proc export data=sellersheet (where=(SeqNo=',SeqNo,')) outfile="/sae/aal_labapm/01/mortgage/msracq/DATA WAREHOUSE/DWACQ/REPORT FILES/MSR0028/&amp;amp;filedate._',seller_name,'.xlsx" DBMS=XLSX REPLACE;sheet="','LOANLIST','"; run;'));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I don't know how I can pull from any dataset to export into individual files if I drop the SeqNo.&amp;nbsp; I must be misunderstanding.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Dec 2020 17:27:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-DATA-to-OUTFILE-Giving-Error/m-p/707723#M217335</guid>
      <dc:creator>elwayfan446</dc:creator>
      <dc:date>2020-12-22T17:27:34Z</dc:date>
    </item>
    <item>
      <title>Re: PROC EXPORT DATA to OUTFILE Giving Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-DATA-to-OUTFILE-Giving-Error/m-p/707724#M217336</link>
      <description>&lt;P&gt;You need to change the code you are generating.&lt;/P&gt;
&lt;P&gt;So instead of starting like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; call execute(cats('proc export&amp;nbsp;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It needs to start with generating the data step to subset the data and drop the variable.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; call execute(cats('data &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I posted example code you need to generate. You just need to translate that into the code needed to generate that code and pass it to CALL EXECUTE.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Dec 2020 17:58:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-DATA-to-OUTFILE-Giving-Error/m-p/707724#M217336</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-12-22T17:58:40Z</dc:date>
    </item>
    <item>
      <title>Re: PROC EXPORT DATA to OUTFILE Giving Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-DATA-to-OUTFILE-Giving-Error/m-p/707764#M217349</link>
      <description>&lt;P&gt;I am still not following on how generating this code will translate into the export of multiple excel files along with being able to use the variables I don't want included in the file name of the excel files.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I generate the code you posted above:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data for_export ;
  set ORIGINAL;
  where seqno='xxx';
  drop seqno;
run;
proc export data=for_export ....&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In the where clause, what am I comparing seqno to?&amp;nbsp; The ORIGINAL dataset?&amp;nbsp; I need all the records from it so I am not trying to filter anything out.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am sorry... I am just not understanding.&amp;nbsp; I am trying for 2 objectives here and that might be what is muddying the water.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;I need to create a separate excel file from the sellersheet dataset that includes all records with the same sequence number (one file per sequence number/lender)&lt;/LI&gt;
&lt;LI&gt;I need the file name of the excel files to include seller_name of each record in that dataset, however, I don't want seqno or seller_name included in the actual data.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Originally, with this code I achieved getting the seller name in the file.&amp;nbsp; It creates a dataset called loop so that the EXECUTE() statement can loop through and create a new file every time it sees a new seqno.&amp;nbsp; That is why I have to include it in the where clause of the EXECUTE().&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=sellersheet out=loop (keep=SeqNo seller_name)nodupkey;
by SeqNo;
run;

data _null_;
  set loop;
  call execute(cats('proc export data=sellersheet (where=(SeqNo=',SeqNo,')) outfile="/sae/aal_labapm/01/mortgage/msracq/DATA WAREHOUSE/DWACQ/REPORT FILES/MSR0028/&amp;amp;filedate._',seller_name,'.xlsx" DBMS=XLSX REPLACE;sheet="','LOANLIST','"; run;'));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Dec 2020 20:58:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-DATA-to-OUTFILE-Giving-Error/m-p/707764#M217349</guid>
      <dc:creator>elwayfan446</dc:creator>
      <dc:date>2020-12-22T20:58:56Z</dc:date>
    </item>
    <item>
      <title>Re: PROC EXPORT DATA to OUTFILE Giving Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-DATA-to-OUTFILE-Giving-Error/m-p/707770#M217354</link>
      <description>&lt;P&gt;I am not sure what is confusing.&amp;nbsp; Currently you are&amp;nbsp;using a data step to generate multiple PROC EXPORT steps.&amp;nbsp; Each time through the data step you are generating code like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc export data=sellersheet (where=(SeqNo='xxx')) 
  outfile="/sae/aal_labapm/01/mortgage/msracq/DATA WAREHOUSE/DWACQ/REPORT FILES/MSR0028/YYYYYY_ZZZZZZ.xlsx" 
  DBMS=XLSX REPLACE
;
  sheet="LOANLIST"; 
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Instead your data step needs to generate first a data step and then the proc export step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Personally I prefer to use the PUT statement to write the generated code to a file instead of using CALL EXECUTE.&amp;nbsp; Then you can review the generated code and make sure the syntax is correct.&amp;nbsp; Once you are sure the data step is generating valid code you just add a %INCLUDE statement to run the generated statements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Dec 2020 21:29:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-DATA-to-OUTFILE-Giving-Error/m-p/707770#M217354</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-12-22T21:29:38Z</dc:date>
    </item>
    <item>
      <title>Re: PROC EXPORT DATA to OUTFILE Giving Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-DATA-to-OUTFILE-Giving-Error/m-p/707786#M217363</link>
      <description>&lt;P&gt;The confusing part is how I get what I need when I perform the data step for the export file.&amp;nbsp; In your where clause example, you are using a constant&lt;/P&gt;
&lt;PRE class="language-sas"&gt;&lt;CODE&gt;(where=(SeqNo='xxx')) &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;To export the data to each spreadsheet based on the SeqNo from the original dataset (sellersheet) I have to pass the SeqNo to the proc export statement.&amp;nbsp; If I am creating a new dataset to use for the export and dropping the SeqNo so it doesn't show up in the data in each of the files, how will that work any differently?&lt;/P&gt;</description>
      <pubDate>Tue, 22 Dec 2020 23:39:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-DATA-to-OUTFILE-Giving-Error/m-p/707786#M217363</guid>
      <dc:creator>elwayfan446</dc:creator>
      <dc:date>2020-12-22T23:39:34Z</dc:date>
    </item>
    <item>
      <title>Re: PROC EXPORT DATA to OUTFILE Giving Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-DATA-to-OUTFILE-Giving-Error/m-p/707915#M217438</link>
      <description>&lt;P&gt;Good morning &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is my latest crack at it but doing this now puts all records from the dataset into each excel spreadsheet.&amp;nbsp; I can't make the connection to only export the records for each seqno (seller_name) into their own spreadsheet.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data _null_;
  set loop;
  call execute(cats(
  				'proc sort data=sellersheet out=loop (keep=SeqNo seller_name)nodupkey;
				 by SeqNo;
				 run;

  				 data for_export;
				   set sellersheet;
				   where seqno=SeqNo;
				   drop seqno;
				 run;

				 proc export data=for_export 
				   outfile="/sae/aal_labapm/01/mortgage/msracq/DATA WAREHOUSE/DWACQ/REPORT FILES/MSR0028/&amp;amp;filedate._',seller_name,'.xlsx" 
				   DBMS=XLSX REPLACE;
				   sheet="','LOANLIST','"; 
				   run;'
			)	);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 Dec 2020 16:01:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-EXPORT-DATA-to-OUTFILE-Giving-Error/m-p/707915#M217438</guid>
      <dc:creator>elwayfan446</dc:creator>
      <dc:date>2020-12-23T16:01:48Z</dc:date>
    </item>
  </channel>
</rss>

