<?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: How to use relative path to define files in SAS? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-relative-path-to-define-files-in-SAS/m-p/427152#M105315</link>
    <description>&lt;P&gt;You don't need filename statements to create datasets??&amp;nbsp; You create a library reference to a physical path, something like:&lt;/P&gt;
&lt;PRE&gt;&lt;FONT color="#003399"&gt;libname mydata '/folders/myfolders/';&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;I believe the /folders/ is the default area.&amp;nbsp; Then you simply use that library reference in your code to create a dataset:&lt;/P&gt;
&lt;PRE&gt;data mydata.class;
  set sashelp.class;
run;&lt;/PRE&gt;
&lt;P&gt;It may be a good idea to focus on the basics of the SAS environment and Base SAS programming, before jumping into Macro whic is an advanced topic and useful only in certain circumstances.&lt;/P&gt;</description>
    <pubDate>Fri, 12 Jan 2018 11:26:15 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2018-01-12T11:26:15Z</dc:date>
    <item>
      <title>How to use relative path to define files in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-relative-path-to-define-files-in-SAS/m-p/427148#M105311</link>
      <description>&lt;P&gt;I'm trying to write a macro defining a file using FILENAME statement&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let pathname= ~/NHAMCS/;
%macro assign(name =, file = );
	FILENAME name &amp;amp;pathname..&amp;amp;file;
%mend assign;

%assign(name = demo03, file = demo03.txt);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;When I call the macro, it gave errors said physical files do not exist. Can anyone show me how to do it correct?&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2018 10:56:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-relative-path-to-define-files-in-SAS/m-p/427148#M105311</guid>
      <dc:creator>Viveme789</dc:creator>
      <dc:date>2018-01-12T10:56:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to use relative path to define files in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-relative-path-to-define-files-in-SAS/m-p/427150#M105313</link>
      <description>&lt;P&gt;What software are you using, and relative to what?&amp;nbsp; What is this supposed to be?&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token operator"&gt;~&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;NHAMCS&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;There are ways, but its different between the different versions of SAS (EG for instance is different to Base), and I would question why you need this in the first place.&amp;nbsp; If you want to store a file, you should know where you want to put it.&amp;nbsp; Even if its just a folder from a base point:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2018 11:20:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-relative-path-to-define-files-in-SAS/m-p/427150#M105313</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-01-12T11:20:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to use relative path to define files in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-relative-path-to-define-files-in-SAS/m-p/427151#M105314</link>
      <description>&lt;P&gt;SAS university edition. I only need create a dataset but using FILENAME statement&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2018 11:21:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-relative-path-to-define-files-in-SAS/m-p/427151#M105314</guid>
      <dc:creator>Viveme789</dc:creator>
      <dc:date>2018-01-12T11:21:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to use relative path to define files in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-relative-path-to-define-files-in-SAS/m-p/427152#M105315</link>
      <description>&lt;P&gt;You don't need filename statements to create datasets??&amp;nbsp; You create a library reference to a physical path, something like:&lt;/P&gt;
&lt;PRE&gt;&lt;FONT color="#003399"&gt;libname mydata '/folders/myfolders/';&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;I believe the /folders/ is the default area.&amp;nbsp; Then you simply use that library reference in your code to create a dataset:&lt;/P&gt;
&lt;PRE&gt;data mydata.class;
  set sashelp.class;
run;&lt;/PRE&gt;
&lt;P&gt;It may be a good idea to focus on the basics of the SAS environment and Base SAS programming, before jumping into Macro whic is an advanced topic and useful only in certain circumstances.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2018 11:26:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-relative-path-to-define-files-in-SAS/m-p/427152#M105315</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-01-12T11:26:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to use relative path to define files in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-relative-path-to-define-files-in-SAS/m-p/427155#M105317</link>
      <description>&lt;P&gt;The tilde is often used to represent the user's home directory, eg in http URL's. But operating systems don't recognize that.&lt;/P&gt;
&lt;P&gt;In UNIX, you should use the environment variable HOME, so your %let would look like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let pathname= $HOME/NHAMCS/;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The nearest Windows equivalent would be %user%, which needs macro masking functions in SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But since you use SAS UE (which runs on UNIX), you should keep all your files in /folders/myfolder, or subdirectories of that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2018 11:35:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-relative-path-to-define-files-in-SAS/m-p/427155#M105317</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-01-12T11:35:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to use relative path to define files in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-relative-path-to-define-files-in-SAS/m-p/427157#M105318</link>
      <description>&lt;P&gt;BTW your macro should correctly use its parameters:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro assign(name=, file=);
filename &amp;amp;name "&amp;amp;pathname.&amp;amp;file"; /* only 1 dot needed */
%mend assign;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Since calling the macro will be almost the same amount of typing than just using the filename statement as is, the macro is unnecessary and will only obfuscate your code by adding a useless level of indirection that makes the code less maintainable.&lt;/P&gt;
&lt;P&gt;Don't (ab)use the macro facility just because it is there, use it for a purpose.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2018 11:40:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-relative-path-to-define-files-in-SAS/m-p/427157#M105318</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-01-12T11:40:29Z</dc:date>
    </item>
  </channel>
</rss>

