<?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: Automate in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Automate/m-p/37554#M7446</link>
    <description>I assume this is going in a macro?  Use %scan().&lt;BR /&gt;
&lt;BR /&gt;
%macro a;&lt;BR /&gt;
%put %scan("feed_cvs_cph_20101031.xls",2,_);&lt;BR /&gt;
%mend;&lt;BR /&gt;
&lt;BR /&gt;
%a</description>
    <pubDate>Fri, 19 Nov 2010 21:05:33 GMT</pubDate>
    <dc:creator>RickM</dc:creator>
    <dc:date>2010-11-19T21:05:33Z</dc:date>
    <item>
      <title>Automate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automate/m-p/37553#M7445</link>
      <description>Automation to create datasets from excel files as shown below:They are all saved in a folder.&lt;BR /&gt;
feed_cvs_cph_20101031.xls&lt;BR /&gt;
feed_walg_cph_20101031.xls&lt;BR /&gt;
feed_apo_cph_20101031.xls&lt;BR /&gt;
&lt;BR /&gt;
So if SAS reads feed_cvs_cph_20101031.xls, dataset cvs is to be created.&lt;BR /&gt;
i.e words between first two undercores are dataset names.</description>
      <pubDate>Fri, 19 Nov 2010 20:56:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automate/m-p/37553#M7445</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2010-11-19T20:56:44Z</dc:date>
    </item>
    <item>
      <title>Re: Automate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automate/m-p/37554#M7446</link>
      <description>I assume this is going in a macro?  Use %scan().&lt;BR /&gt;
&lt;BR /&gt;
%macro a;&lt;BR /&gt;
%put %scan("feed_cvs_cph_20101031.xls",2,_);&lt;BR /&gt;
%mend;&lt;BR /&gt;
&lt;BR /&gt;
%a</description>
      <pubDate>Fri, 19 Nov 2010 21:05:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automate/m-p/37554#M7446</guid>
      <dc:creator>RickM</dc:creator>
      <dc:date>2010-11-19T21:05:33Z</dc:date>
    </item>
    <item>
      <title>Re: Automate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automate/m-p/37555#M7447</link>
      <description>Hi.I found the code I writed before.&lt;BR /&gt;
But not test it, You can refer to it.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
%let subdir=D:\sasdata\;&lt;BR /&gt;
filename dir pipe "dir &amp;amp;subdir.*.xls /B";&lt;BR /&gt;
data new;&lt;BR /&gt;
 infile dir truncover end=last;&lt;BR /&gt;
 input filename  $100.;&lt;BR /&gt;
 filename=cats("&amp;amp;subdir",filename);&lt;BR /&gt;
 call symputx(cats('path',_n_),filename);&lt;BR /&gt;
 call symputx(cats('dsn',_n_),scan(scan(filename,3,'\'),2,'_'));&lt;BR /&gt;
 if last then call symputx('nobs',_n_);&lt;BR /&gt;
run;&lt;BR /&gt;
%put _user_;&lt;BR /&gt;
%macro import;&lt;BR /&gt;
%do i=1 %to &amp;amp;nobs;&lt;BR /&gt;
proc import datafile="&amp;amp;&amp;amp;path&amp;amp;i" out=&amp;amp;&amp;amp;dsn&amp;amp;i dbms=excel replace;&lt;BR /&gt;
                                              getnames=yes;&lt;BR /&gt;
											  run;&lt;BR /&gt;
%end;&lt;BR /&gt;
%mend import;&lt;BR /&gt;
&lt;BR /&gt;
%import&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Mon, 22 Nov 2010 03:21:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automate/m-p/37555#M7447</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2010-11-22T03:21:39Z</dc:date>
    </item>
    <item>
      <title>Re: Automate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automate/m-p/37556#M7448</link>
      <description>Ksharp...That is a sharp solution.Thanks.&lt;BR /&gt;
The export procedure below creates worksheets whether or not qty is greater than 100.if it is not only a blank sheet is created or else only those records that are greater than 100 are created.How to create only those work sheets where qty is greater than 100.say for instance there are 10 datasets and only 3 of them meet the where condition, we need only those 3 .no need to output blank worksheets for other 7.&lt;BR /&gt;
proc export data=test&amp;amp;i.(where=(lqty&amp;gt;=100))&lt;BR /&gt;
   outfile='H:\PJ\Outliers\Outfiles\outliers-%sysfunc(date(),mmddyyd10.).xls'&lt;BR /&gt;
   dbms=excel2000&lt;BR /&gt;
   replace;&lt;BR /&gt;
   SHEET=%scan("&amp;amp;&amp;amp;path&amp;amp;i",2,_);&lt;BR /&gt;
run;</description>
      <pubDate>Tue, 23 Nov 2010 15:03:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automate/m-p/37556#M7448</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2010-11-23T15:03:33Z</dc:date>
    </item>
    <item>
      <title>Re: Automate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automate/m-p/37557#M7449</link>
      <description>Sorry.I have no clue about this .&lt;BR /&gt;
Maybe you need to judge the number of observations of sub-dataset to decide to call macro.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
proc sql;&lt;BR /&gt;
 select nobs&lt;BR /&gt;
  into  :_nobs&lt;BR /&gt;
  from dictionary.tables&lt;BR /&gt;
   where libname ='WORK' and memname='TABLENAME';quit;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
if &amp;amp;nobs ne 0 then ' proc export '&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp

Message was edited by: Ksharp</description>
      <pubDate>Wed, 24 Nov 2010 03:12:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automate/m-p/37557#M7449</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2010-11-24T03:12:08Z</dc:date>
    </item>
    <item>
      <title>Re: Automate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automate/m-p/37558#M7450</link>
      <description>&amp;gt; The export procedure below creates worksheets whether&lt;BR /&gt;
&amp;gt; or not qty is greater than 100.if it is not only a&lt;BR /&gt;
&amp;gt; blank sheet is created or else only those records&lt;BR /&gt;
&amp;gt; that are greater than 100 are created.How to create&lt;BR /&gt;
&amp;gt; only those work sheets where qty is greater than&lt;BR /&gt;
&amp;gt; 100.say for instance there are 10 datasets and only 3&lt;BR /&gt;
&amp;gt; of them meet the where condition, we need only those&lt;BR /&gt;
&amp;gt; 3 .no need to output blank worksheets for other 7.&lt;BR /&gt;
&amp;gt; proc export data=test&amp;amp;i.(where=(lqty&amp;gt;=100))&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; utfile='H:\PJ\Outliers\Outfiles\outliers-%sysfunc(date&lt;BR /&gt;
&amp;gt; (),mmddyyd10.).xls'&lt;BR /&gt;
&amp;gt;    dbms=excel2000&lt;BR /&gt;
&amp;gt; replace;&lt;BR /&gt;
&amp;gt;    SHEET=%scan("&amp;amp;&amp;amp;path&amp;amp;i",2,_);&lt;BR /&gt;
&amp;gt; ;&lt;BR /&gt;
&lt;BR /&gt;
package the process (with macro or call execute) to first check whether there are relevant observations, and only when any are found, launch the step to write to excel.&lt;BR /&gt;
For example:&lt;BR /&gt;
%let age = 25 ;&lt;BR /&gt;
data _null_ ; &lt;BR /&gt;
  set sashelp.class ;&lt;BR /&gt;
  where age &amp;gt; &amp;amp;age ;&lt;BR /&gt;
  call execute( ' &lt;BR /&gt;
proc print data= sashelp.class;&lt;BR /&gt;
where age&amp;gt;&amp;amp;age; &lt;BR /&gt;
run ;&lt;BR /&gt;
');&lt;BR /&gt;
stop ;&lt;BR /&gt;
run;&lt;BR /&gt;
There are no obs in sashelp.class with age &amp;gt; 16 so for 25 the proc print syntax will not be "executed".&lt;BR /&gt;
when you try it with&lt;BR /&gt;
%let age=15 ;&lt;BR /&gt;
you get a row through the where clause and that causes the proc print syntax to be submitted.&lt;BR /&gt;
&lt;BR /&gt;
You can replace the proc print syntax with your proc report syntax.</description>
      <pubDate>Wed, 24 Nov 2010 16:29:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automate/m-p/37558#M7450</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2010-11-24T16:29:50Z</dc:date>
    </item>
  </channel>
</rss>

