<?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 Dynamic Libname pcfiles statement with single quote in workbook name in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-Libname-pcfiles-statement-with-single-quote-in-workbook/m-p/308349#M66164</link>
    <description>&lt;P&gt;So far, I have created a series of macros that&amp;nbsp;creates a dataset containing a list of&amp;nbsp;file names and the subfolder in which they reside within a folder. Thanks to&amp;nbsp;&lt;A href="http://www2.sas.com/proceedings/sugi26/p093-26.pdf.&amp;nbsp;" target="_blank"&gt;http://www2.sas.com/proceedings/sugi26/p093-26.pdf.&amp;nbsp;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my dataset&amp;nbsp;&lt;SPAN&gt;Fldrsnfiles there are two variables: Fldr and File. As an example,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Fldr=Apr 2016; &amp;nbsp;/* &amp;nbsp;the value of the Fldr field in my dataset */&lt;/P&gt;&lt;P&gt;File=04-01-16 pk trf's.xlsx; /* the value of the file field in my dataset - problem area*/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The goal now is to use a similar macro to dynamically change a libname statement to read all the files in the main sub the file. But some of the file names have singe quotes in them!!!! YUCK!! This is creating an unquoted string problem when I run the macro below. &amp;nbsp;I need away for the program to ignore single quotes in the File variable. Thank you everyone.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro extractdata(scanfile, Field1, Field2);&lt;BR /&gt;/* first obtain the number of records in the folderNames dataset*/&lt;/P&gt;&lt;P&gt;data _NULL_;&lt;BR /&gt;IF 0 then SET &amp;amp;SCANFILE NOBS=X;&lt;BR /&gt;Call SYMPUT('RECCOUNT',X);&lt;BR /&gt;STOP;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;/* Loop from one to number of records */&lt;BR /&gt;%DO I=1 %To &amp;amp;RECCOUNT;&lt;/P&gt;&lt;P&gt;/* advanced to the Ith record*/&lt;BR /&gt;DATA _NULL_;&lt;BR /&gt;SET &amp;amp;SCANFILE (FIRSTOBS=&amp;amp;I);&lt;BR /&gt;/*store the foldername and filename in macro variables*/&lt;BR /&gt;CALL SYMPUT('SubFolder', FLDR);&lt;BR /&gt;CALL SYMPUT('File', FILE);&lt;BR /&gt;&lt;BR /&gt;STOP;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;/* perform getting all the file names with name of subfolder into a dataset*/&lt;BR /&gt;libname ACH pcfiles Path= "&amp;amp;Location&amp;amp;LoopFldr\&amp;amp;LoopFile";&lt;/P&gt;&lt;P&gt;title "&amp;amp;SubFolder&amp;amp;File";&lt;BR /&gt;Proc print data= ACH.'Sheet1$'n; run;&lt;BR /&gt;title;&lt;/P&gt;&lt;P&gt;libname ACH clear;&lt;/P&gt;&lt;P&gt;%end; /*end of Do */&lt;/P&gt;&lt;P&gt;%MEND extractdata;&lt;/P&gt;&lt;P&gt;%extractdata(scanfile=Fldrsnfiles, Field1=FLDR, Field2=file);&lt;/P&gt;</description>
    <pubDate>Mon, 31 Oct 2016 19:01:57 GMT</pubDate>
    <dc:creator>KRusso</dc:creator>
    <dc:date>2016-10-31T19:01:57Z</dc:date>
    <item>
      <title>Dynamic Libname pcfiles statement with single quote in workbook name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-Libname-pcfiles-statement-with-single-quote-in-workbook/m-p/308349#M66164</link>
      <description>&lt;P&gt;So far, I have created a series of macros that&amp;nbsp;creates a dataset containing a list of&amp;nbsp;file names and the subfolder in which they reside within a folder. Thanks to&amp;nbsp;&lt;A href="http://www2.sas.com/proceedings/sugi26/p093-26.pdf.&amp;nbsp;" target="_blank"&gt;http://www2.sas.com/proceedings/sugi26/p093-26.pdf.&amp;nbsp;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my dataset&amp;nbsp;&lt;SPAN&gt;Fldrsnfiles there are two variables: Fldr and File. As an example,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Fldr=Apr 2016; &amp;nbsp;/* &amp;nbsp;the value of the Fldr field in my dataset */&lt;/P&gt;&lt;P&gt;File=04-01-16 pk trf's.xlsx; /* the value of the file field in my dataset - problem area*/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The goal now is to use a similar macro to dynamically change a libname statement to read all the files in the main sub the file. But some of the file names have singe quotes in them!!!! YUCK!! This is creating an unquoted string problem when I run the macro below. &amp;nbsp;I need away for the program to ignore single quotes in the File variable. Thank you everyone.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro extractdata(scanfile, Field1, Field2);&lt;BR /&gt;/* first obtain the number of records in the folderNames dataset*/&lt;/P&gt;&lt;P&gt;data _NULL_;&lt;BR /&gt;IF 0 then SET &amp;amp;SCANFILE NOBS=X;&lt;BR /&gt;Call SYMPUT('RECCOUNT',X);&lt;BR /&gt;STOP;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;/* Loop from one to number of records */&lt;BR /&gt;%DO I=1 %To &amp;amp;RECCOUNT;&lt;/P&gt;&lt;P&gt;/* advanced to the Ith record*/&lt;BR /&gt;DATA _NULL_;&lt;BR /&gt;SET &amp;amp;SCANFILE (FIRSTOBS=&amp;amp;I);&lt;BR /&gt;/*store the foldername and filename in macro variables*/&lt;BR /&gt;CALL SYMPUT('SubFolder', FLDR);&lt;BR /&gt;CALL SYMPUT('File', FILE);&lt;BR /&gt;&lt;BR /&gt;STOP;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;/* perform getting all the file names with name of subfolder into a dataset*/&lt;BR /&gt;libname ACH pcfiles Path= "&amp;amp;Location&amp;amp;LoopFldr\&amp;amp;LoopFile";&lt;/P&gt;&lt;P&gt;title "&amp;amp;SubFolder&amp;amp;File";&lt;BR /&gt;Proc print data= ACH.'Sheet1$'n; run;&lt;BR /&gt;title;&lt;/P&gt;&lt;P&gt;libname ACH clear;&lt;/P&gt;&lt;P&gt;%end; /*end of Do */&lt;/P&gt;&lt;P&gt;%MEND extractdata;&lt;/P&gt;&lt;P&gt;%extractdata(scanfile=Fldrsnfiles, Field1=FLDR, Field2=file);&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2016 19:01:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-Libname-pcfiles-statement-with-single-quote-in-workbook/m-p/308349#M66164</guid>
      <dc:creator>KRusso</dc:creator>
      <dc:date>2016-10-31T19:01:57Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Libname pcfiles statement with single quote in workbook name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-Libname-pcfiles-statement-with-single-quote-in-workbook/m-p/308371#M66168</link>
      <description>&lt;P&gt;Use %BQUOTE might help you.&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;%&lt;STRONG&gt;&lt;I&gt;extractdata&lt;/I&gt;&lt;/STRONG&gt;(scanfile=Fldrsnfiles, Field1=FLDR, Field2=&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%BQUOTE&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(file));&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;For more information this paper might be helpful to you.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;A href="http://www2.sas.com/proceedings/forum2007/152-2007.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/forum2007/152-2007.pdf&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2016 19:54:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-Libname-pcfiles-statement-with-single-quote-in-workbook/m-p/308371#M66168</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2016-10-31T19:54:11Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Libname pcfiles statement with single quote in workbook name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-Libname-pcfiles-statement-with-single-quote-in-workbook/m-p/308406#M66182</link>
      <description>Elegant, simple, and excellent reference to handle future issues with macros and quotes. I know that I'll come across this again and be sharing it with others. 1000 Thank yous!</description>
      <pubDate>Tue, 01 Nov 2016 01:05:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-Libname-pcfiles-statement-with-single-quote-in-workbook/m-p/308406#M66182</guid>
      <dc:creator>KRusso</dc:creator>
      <dc:date>2016-11-01T01:05:01Z</dc:date>
    </item>
  </channel>
</rss>

