<?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 Is there a way to retrieve the hostname? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-retrieve-the-hostname/m-p/11451#M1061</link>
    <description>Hello everyone,&lt;BR /&gt;
When testing one of our sas scripts on the development server we have to configure things slightly differently in the script (libnames pointing at different locations mainly), however it would be really useful if the script could automatically detect the hostname of the server it is currently running on. Does anyone know of a way to do this?&lt;BR /&gt;
The help file plus google have not provided me with a solution yet.&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
~Toby</description>
    <pubDate>Thu, 26 Mar 2009 10:12:02 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2009-03-26T10:12:02Z</dc:date>
    <item>
      <title>Is there a way to retrieve the hostname?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-retrieve-the-hostname/m-p/11451#M1061</link>
      <description>Hello everyone,&lt;BR /&gt;
When testing one of our sas scripts on the development server we have to configure things slightly differently in the script (libnames pointing at different locations mainly), however it would be really useful if the script could automatically detect the hostname of the server it is currently running on. Does anyone know of a way to do this?&lt;BR /&gt;
The help file plus google have not provided me with a solution yet.&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
~Toby</description>
      <pubDate>Thu, 26 Mar 2009 10:12:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-retrieve-the-hostname/m-p/11451#M1061</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-03-26T10:12:02Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to retrieve the hostname?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-retrieve-the-hostname/m-p/11452#M1062</link>
      <description>HI,&lt;BR /&gt;
&lt;BR /&gt;
I saw something about this yesterday actually. It seems v9.2 has a automatic macro variable called %syshostname&lt;BR /&gt;
&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/whatsnew/62435/HTML/default/mcrolrefwhatsnew902.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/whatsnew/62435/HTML/default/mcrolrefwhatsnew902.htm&lt;/A&gt;</description>
      <pubDate>Thu, 26 Mar 2009 10:23:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-retrieve-the-hostname/m-p/11452#M1062</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-03-26T10:23:14Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to retrieve the hostname?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-retrieve-the-hostname/m-p/11453#M1063</link>
      <description>Sadly I believe we are using 9.1 (tried %put &amp;amp;syshostname; but that returned an error).&lt;BR /&gt;
&lt;BR /&gt;
~T</description>
      <pubDate>Thu, 26 Mar 2009 12:04:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-retrieve-the-hostname/m-p/11453#M1063</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-03-26T12:04:26Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to retrieve the hostname?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-retrieve-the-hostname/m-p/11454#M1064</link>
      <description>read the environment variables. One will be the computername or hostname. It is platform  dependant. Once you discover which, you can retrieve it with &lt;BR /&gt;
%let host= %SYSGET(envVarName);&lt;BR /&gt;
 &lt;BR /&gt;
PeterC</description>
      <pubDate>Sat, 28 Mar 2009 18:09:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-retrieve-the-hostname/m-p/11454#M1064</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-03-28T18:09:50Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to retrieve the hostname?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-retrieve-the-hostname/m-p/11455#M1065</link>
      <description>Another way of doing that would be piping the result of hostname command:&lt;BR /&gt;
&lt;BR /&gt;
data _null_;&lt;BR /&gt;
      infile 'hostname' pipe; /* pipe result of hostname comand */&lt;BR /&gt;
      hostname=_infile_; /* _infile_ is the input buffer */&lt;BR /&gt;
      put hostname=;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
this works on both UNIX and Windows systems.&lt;BR /&gt;
&lt;BR /&gt;
Greetings from Portugal.&lt;BR /&gt;
&lt;BR /&gt;
Daniel Santos at &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;</description>
      <pubDate>Wed, 01 Apr 2009 09:56:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-retrieve-the-hostname/m-p/11455#M1065</guid>
      <dc:creator>DanielSantos</dc:creator>
      <dc:date>2009-04-01T09:56:38Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to retrieve the hostname?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-retrieve-the-hostname/m-p/11456#M1066</link>
      <description>You forgot one statement INPUT;&lt;BR /&gt;
[pre]&lt;BR /&gt;
data _null_;&lt;BR /&gt;
   infile 'hostname' pipe; /* pipe result of hostname comand */&lt;BR /&gt;
   input;&lt;BR /&gt;
   hostname=_infile_; /* _infile_ is the input buffer */&lt;BR /&gt;
   put hostname=;&lt;BR /&gt;
   run;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Wed, 01 Apr 2009 10:54:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-retrieve-the-hostname/m-p/11456#M1066</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2009-04-01T10:54:27Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to retrieve the hostname?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-retrieve-the-hostname/m-p/11457#M1067</link>
      <description>Yep. True.&lt;BR /&gt;
&lt;BR /&gt;
Thanks.&lt;BR /&gt;
&lt;BR /&gt;
Greetings from Portugal.&lt;BR /&gt;
&lt;BR /&gt;
Daniel Santos at &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;</description>
      <pubDate>Wed, 01 Apr 2009 15:43:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-retrieve-the-hostname/m-p/11457#M1067</guid>
      <dc:creator>DanielSantos</dc:creator>
      <dc:date>2009-04-01T15:43:11Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to retrieve the hostname?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-retrieve-the-hostname/m-p/323730#M71794</link>
      <description>&lt;P&gt;Use &amp;amp;syshostname instead of %syshostname&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;% is used to identify a macro, but &amp;amp; is used to show the value of a macro variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Needless to say, it's important to know the difference between a macro and a macro variable, but most people just call them macros.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jan 2017 18:31:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-retrieve-the-hostname/m-p/323730#M71794</guid>
      <dc:creator>RedPlanet</dc:creator>
      <dc:date>2017-01-10T18:31:24Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to retrieve the hostname?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-retrieve-the-hostname/m-p/323841#M71840</link>
      <description>&lt;P&gt;Whenever I can influence things, then I make sure that directory structures are identical between environments. I don't think coding&amp;nbsp;environment smart within individual scripts is a good approach.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What's sometimes different is the "Root path". What I'm normally doing in such a case is to implement SAS macro variables in the Autoexec and so I keep all environment specific information in a single location for maintenance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A libname statement would then look like:&lt;/P&gt;
&lt;P&gt;libname myds "&amp;amp;data\subfolder1\subfolder2";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Where the "subfolders" are the part of the directory structure under my control and identical in all environments.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;An alternative approach for libraries used in multiple programs would be, to define these libraries in SAS Metadata. This is again about keeping environment specific things in a central location and not spread out over many programs which becomes a maintenance nightmare in case something ever changes - and for example the host name will change when you upgrade to a current SAS version in a hopefully not too far future for you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you don't have the necessary level of access to modify the Autoexec or to change SAS Metadata then a 3rd option would be to create a %init macro with all these environment specific definitions. Store the macro code in a folder which is part of the SAS Autocall facility and then just call the macro always at the beginning of your programs.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jan 2017 02:12:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-retrieve-the-hostname/m-p/323841#M71840</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-01-11T02:12:52Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to retrieve the hostname?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-retrieve-the-hostname/m-p/323889#M71849</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hmmm, somehow I think you posted in the wrong topic.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is a 7 years old discussion &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Daniel Santos&amp;nbsp;@ &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jan 2017 10:45:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-retrieve-the-hostname/m-p/323889#M71849</guid>
      <dc:creator>DanielSantos</dc:creator>
      <dc:date>2017-01-11T10:45:09Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to retrieve the hostname?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-retrieve-the-hostname/m-p/323913#M71852</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13832"&gt;@DanielSantos&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;LOL! How did that happen? No idea how I've even got to such an old thread.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jan 2017 13:19:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-retrieve-the-hostname/m-p/323913#M71852</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-01-11T13:19:38Z</dc:date>
    </item>
  </channel>
</rss>

