<?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: using macro to create libname in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/using-macro-to-create-libname/m-p/78737#M17022</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I dont think you need a macro at all. But the error could be caused by missing quotes in your system function call.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 08 Jun 2012 14:53:59 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2012-06-08T14:53:59Z</dc:date>
    <item>
      <title>using macro to create libname</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-macro-to-create-libname/m-p/78736#M17021</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the below code I am using a macro to create a folder if doesn't exist and use the same folder to assign a libname. When i run the code&amp;nbsp; for the first time the folder create step works fine but the libname is not getting assigned.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, if i run the same code again in the same session the libname is getting successfully assigned.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Options noxwait;&lt;/P&gt;&lt;P&gt;%Let monyyyy = %sysfunc(putn(%sysfunc(today()),monyy7.));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%Macro chk;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data _null_;&lt;/P&gt;&lt;P&gt;if not fileexist("C:\Reports\&amp;amp;monyyyy.\&amp;amp;sysdate.") then rc=system("mkdir "C:\Reports\&amp;amp;monyyyy.\&amp;amp;sysdate.");&lt;/P&gt;&lt;P&gt;Run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%Let fpath = C:\Reports\&amp;amp;monyyyy.\&amp;amp;sysdate.;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;libname rep "&amp;amp;fpath.";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%Mend;&lt;/P&gt;&lt;P&gt;%Chk;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Does anybody have any idea, why is this happening.? Any help would be appreciated.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Jun 2012 14:33:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-macro-to-create-libname/m-p/78736#M17021</guid>
      <dc:creator>vicky07</dc:creator>
      <dc:date>2012-06-08T14:33:16Z</dc:date>
    </item>
    <item>
      <title>Re: using macro to create libname</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-macro-to-create-libname/m-p/78737#M17022</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I dont think you need a macro at all. But the error could be caused by missing quotes in your system function call.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Jun 2012 14:53:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-macro-to-create-libname/m-p/78737#M17022</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2012-06-08T14:53:59Z</dc:date>
    </item>
    <item>
      <title>Re: using macro to create libname</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-macro-to-create-libname/m-p/78738#M17023</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;PG,&lt;/P&gt;&lt;P&gt;Thanks for the reply. I didn't list the entire code&amp;nbsp; here and i have some steps after the libname which requires Macro. Actually, there was &lt;STRONG&gt;no quotes in my original code&lt;/STRONG&gt; I typed it incorrectly in the forum, good catch though. I removed the quotes in the below code. Please let me know if you think something else could be causing the error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;%Let monyyyy = %sysfunc(putn(%sysfunc(today()),monyy7.));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;%Macro chk;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Data _null_;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;if not fileexist("C:\Reports\&amp;amp;monyyyy.\&amp;amp;sysdate.") then rc=system("mkdir C:\Reports\&amp;amp;monyyyy.\&amp;amp;sysdate.");&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;%Let fpath = C:\Reports\&amp;amp;monyyyy.\&amp;amp;sysdate.;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;libname rep "&amp;amp;fpath.";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;%Mend;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;%Chk;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Jun 2012 15:21:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-macro-to-create-libname/m-p/78738#M17023</guid>
      <dc:creator>vicky07</dc:creator>
      <dc:date>2012-06-08T15:21:00Z</dc:date>
    </item>
    <item>
      <title>Re: using macro to create libname</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-macro-to-create-libname/m-p/78739#M17024</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would try removing the unneeded periods after &amp;amp;sysdate and &amp;amp;fpath. The example code then works on my system.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Jun 2012 15:30:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-macro-to-create-libname/m-p/78739#M17024</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2012-06-08T15:30:48Z</dc:date>
    </item>
    <item>
      <title>Re: using macro to create libname</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-macro-to-create-libname/m-p/78740#M17025</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Removing the periods worked. Thank you very much!!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Jun 2012 16:03:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-macro-to-create-libname/m-p/78740#M17025</guid>
      <dc:creator>vicky07</dc:creator>
      <dc:date>2012-06-08T16:03:37Z</dc:date>
    </item>
    <item>
      <title>Re: using macro to create libname</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-macro-to-create-libname/m-p/78741#M17026</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The trailing periods looked fine before, perhaps you removed some spaces when you removed the periods?&amp;nbsp; Using proportional fonts can make that type of thing very hard to see.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It would be easier and less error prone to assign the FPATH macro variable and then use it.&amp;nbsp; Then you have the logic for building the path in one place instead of three.&lt;/P&gt;&lt;P&gt;You also might want to quote the path when passing it to the mkdir command. Many DOS commands require quotes to handle paths with embedded spaces correctly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%Let monyyyy = %sysfunc(putn(%sysfunc(today()),monyy7.));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%macro chk;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier; background-color: #ffffff;"&gt;%Let fpath = C:\Reports\&amp;amp;monyyyy\&amp;amp;sysdate;&lt;/SPAN&gt; &lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data _null_;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; if not fileexist("&amp;amp;fpath") then rc=system("mkdir ""&amp;amp;fpath""");&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;libname rep "&amp;amp;fpath";&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%mend chk;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%chk;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 Jun 2012 00:12:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-macro-to-create-libname/m-p/78741#M17026</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-06-09T00:12:52Z</dc:date>
    </item>
    <item>
      <title>Re: using macro to create libname</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-macro-to-create-libname/m-p/78742#M17027</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tom,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your solution make sense and it worked. Thanks for the reply!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 Jun 2012 04:13:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-macro-to-create-libname/m-p/78742#M17027</guid>
      <dc:creator>vicky07</dc:creator>
      <dc:date>2012-06-09T04:13:11Z</dc:date>
    </item>
  </channel>
</rss>

