<?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 program/programming improvement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/program-programming-improvement/m-p/789591#M252682</link>
    <description>&lt;P&gt;Hi SAS Experts&lt;BR /&gt;I apologized about the length of my “question”:&lt;BR /&gt;I run reports every week by pooling data from our SAS daily downloads, extracting whatever needed, performing necessary formatting, table joins, calculations, comparisons…etc. and finally creating Excel spreadsheets that data managers would use for their purposes. I mostly use “proc sql” and the way I do it is that I have a code written and saved as a word document and every week I would change/replace the date in my code, copy and paste the entire code into SAS (probably not the most fortunate way). I have about 20 libraries I create from SAS data downloads and pool different data from - maybe 10 or more conditions per library)&lt;BR /&gt;So the code would look something like this:&lt;BR /&gt;libname newlib 'Z:\SAS_downloads\Today';&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table table1&lt;BR /&gt;select var1 var2&lt;BR /&gt;from newlib.SAS_table&lt;BR /&gt;..&lt;BR /&gt;..&lt;BR /&gt;..&lt;BR /&gt;..&lt;BR /&gt;..&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;proc export&lt;BR /&gt;data=table1 dbms=xlsx&lt;BR /&gt;outfile="\\xxxxxxx\Documents\FILES\Excel_File_date.xlsx"&lt;BR /&gt;replace;&lt;BR /&gt;sheet="Sheet_Date";&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, I compare previous reports and the current one to find new entries using &lt;EM&gt;proc import&lt;/EM&gt; to import current and previous week reports and the &lt;EM&gt;proc sql&lt;/EM&gt; to extract only new entries and, again, &lt;EM&gt;proc export&lt;/EM&gt; to create new excel spread sheet that will be sent to data managers.&lt;BR /&gt;My way is working OK, but, based on number of libraries and conditions I need to run, I think I have way too many repetitions in my code (for some libraries the conditions/data I am extracting are similar, just library names are different) so I am curious if there is a way (or ways) to make the entire process more &lt;STRONG&gt;data-oriented&lt;/STRONG&gt;, optimized and more sophisticated so I can avoid those unnecessary repetitions.&lt;BR /&gt;Thank you very much for dedicating your valuable time to these. Please let me know if you need more details as I wanted to keep this as short as possible. Any suggestion, correction, opinion is highly appreciated.&lt;BR /&gt;Kind regards!&lt;/P&gt;</description>
    <pubDate>Tue, 11 Jan 2022 21:28:52 GMT</pubDate>
    <dc:creator>Batta</dc:creator>
    <dc:date>2022-01-11T21:28:52Z</dc:date>
    <item>
      <title>program/programming improvement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/program-programming-improvement/m-p/789591#M252682</link>
      <description>&lt;P&gt;Hi SAS Experts&lt;BR /&gt;I apologized about the length of my “question”:&lt;BR /&gt;I run reports every week by pooling data from our SAS daily downloads, extracting whatever needed, performing necessary formatting, table joins, calculations, comparisons…etc. and finally creating Excel spreadsheets that data managers would use for their purposes. I mostly use “proc sql” and the way I do it is that I have a code written and saved as a word document and every week I would change/replace the date in my code, copy and paste the entire code into SAS (probably not the most fortunate way). I have about 20 libraries I create from SAS data downloads and pool different data from - maybe 10 or more conditions per library)&lt;BR /&gt;So the code would look something like this:&lt;BR /&gt;libname newlib 'Z:\SAS_downloads\Today';&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table table1&lt;BR /&gt;select var1 var2&lt;BR /&gt;from newlib.SAS_table&lt;BR /&gt;..&lt;BR /&gt;..&lt;BR /&gt;..&lt;BR /&gt;..&lt;BR /&gt;..&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;proc export&lt;BR /&gt;data=table1 dbms=xlsx&lt;BR /&gt;outfile="\\xxxxxxx\Documents\FILES\Excel_File_date.xlsx"&lt;BR /&gt;replace;&lt;BR /&gt;sheet="Sheet_Date";&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, I compare previous reports and the current one to find new entries using &lt;EM&gt;proc import&lt;/EM&gt; to import current and previous week reports and the &lt;EM&gt;proc sql&lt;/EM&gt; to extract only new entries and, again, &lt;EM&gt;proc export&lt;/EM&gt; to create new excel spread sheet that will be sent to data managers.&lt;BR /&gt;My way is working OK, but, based on number of libraries and conditions I need to run, I think I have way too many repetitions in my code (for some libraries the conditions/data I am extracting are similar, just library names are different) so I am curious if there is a way (or ways) to make the entire process more &lt;STRONG&gt;data-oriented&lt;/STRONG&gt;, optimized and more sophisticated so I can avoid those unnecessary repetitions.&lt;BR /&gt;Thank you very much for dedicating your valuable time to these. Please let me know if you need more details as I wanted to keep this as short as possible. Any suggestion, correction, opinion is highly appreciated.&lt;BR /&gt;Kind regards!&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jan 2022 21:28:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/program-programming-improvement/m-p/789591#M252682</guid>
      <dc:creator>Batta</dc:creator>
      <dc:date>2022-01-11T21:28:52Z</dc:date>
    </item>
    <item>
      <title>Re: program/programming improvement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/program-programming-improvement/m-p/789602#M252687</link>
      <description>&lt;P&gt;First a minor comment: Storing SAS code in a WORD document, or other spreadsheet, is next to dangerous. Some of the word processing programs will replace simple programming quotes like ' with a curly quote (or apostrophe) that looks nice in print but means code will not run.&lt;/P&gt;
&lt;P&gt;An example at : &lt;A href="https://communities.sas.com/t5/SAS-Programming/Smart-Quotes-Vs-Simple-Quotes/m-p/396099" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Smart-Quotes-Vs-Simple-Quotes/m-p/396099&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Also some text formatting stuff that you don't see can affect things.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS has function, Today() that will return the value of the current date that the statement executes. So you can test or modify that value with date functions to create other text such&amp;nbsp; as the names of files and such, or to increment a base value to select values with a specific range of days(or weeks, months or years) of that value with the INTCK and/or INTNX functions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since you did not show any example of how you might actually use the date value it is hard to go much further than that.&lt;/P&gt;
&lt;P&gt;If your code is static enough you might be able to use a CALL EXECUTE approach which would let you use a data set containing the main part of the code and insert the appropriate date values into the statements that would depend on the date.&lt;/P&gt;
&lt;P&gt;Another approach is to write the code to use macro values for the date dependent bits and then the program at the top would use the Today function and other statements to set the date dependent bits. Again, it might help to show which parts of your code need to change and the rules involved.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jan 2022 22:06:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/program-programming-improvement/m-p/789602#M252687</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-01-11T22:06:19Z</dc:date>
    </item>
  </channel>
</rss>

