<?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: X Command data variable in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/X-Command-data-variable/m-p/623381#M19924</link>
    <description>&lt;P&gt;+%F is a format qualifier that directs date to output a full format (YYYY-MM-DD).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think that the double quotes around the date call are a mistake, as are the double percent signs. When running this command from SAS, I'd let SAS compute the date.&lt;/P&gt;</description>
    <pubDate>Sun, 09 Feb 2020 08:07:08 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2020-02-09T08:07:08Z</dc:date>
    <item>
      <title>X Command data variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/X-Command-data-variable/m-p/623345#M19913</link>
      <description>&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;Hi,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;Im trying to create a test file with today date in Linux from SAS program using the below query , but I'm not able to result.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;X&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;"bhosts | sed 's/ /,/g' | sed 's/,\{2,\}/,/g' &amp;gt; /home/test&lt;FONT face="Courier New" size="3"&gt;_"$(date +%%F)".&lt;/FONT&gt;txt"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&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;But I when I run directly in Linux the below query&amp;nbsp; its working.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;bhosts | sed 's/ /,/g' |&amp;nbsp; sed 's/,\{2,\}/,/g' &amp;gt; /home/test_"$(date +%F)".txt&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;Whether variable will not able to be passed in X command??? &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;Thanks.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 08 Feb 2020 23:07:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/X-Command-data-variable/m-p/623345#M19913</guid>
      <dc:creator>helannivas88</dc:creator>
      <dc:date>2020-02-08T23:07:04Z</dc:date>
    </item>
    <item>
      <title>Re: X Command data variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/X-Command-data-variable/m-p/623347#M19914</link>
      <description>&lt;P&gt;Do you really want those double quotes in the filename?&lt;/P&gt;</description>
      <pubDate>Sat, 08 Feb 2020 23:49:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/X-Command-data-variable/m-p/623347#M19914</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-02-08T23:49:49Z</dc:date>
    </item>
    <item>
      <title>Re: X Command data variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/X-Command-data-variable/m-p/623358#M19919</link>
      <description>&lt;P&gt;Change the X command to the %PUT statement so you can try to see what you are trying to pass to the X command.&lt;/P&gt;
&lt;PRE&gt;704   %put "bhosts | sed 's/ /,/g' | sed 's/,\{2,\}/,/g' &amp;gt; /home/test_"$(date +%%F)".txt";
"bhosts | sed 's/ /,/g' | sed 's/,\{2,\}/,/g' &amp;gt; /home/test_"$(date +%%F)".txt"
&lt;/PRE&gt;
&lt;P&gt;So you have given the X command a quoted string that starts with bhosts and ends with test_, then the unquoted characters $(date +%%F) and then the quoted string .txt.&amp;nbsp; Note that %F looks like a macro call.&amp;nbsp; Do you actually have a macro named F to call?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Would be much better to wrap the command inside of single quotes to prevent the macro processor from trying to interpret the &amp;amp; and % characters.&amp;nbsp; Since your command already had single quotes in it you need to double them.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;x 'bhosts | sed ''s/ /,/g'' | sed ''s/,\{2,\}/,/g'' &amp;gt; /home/test_"$(date +%F)".txt' ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or convert them to double quotes instead.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;x 'bhosts | sed "s/ /,/g" | sed "s/,\{2,\}/,/g" &amp;gt; /home/test_"$(date +%F)".txt' ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Looks like you are running the bhosts command and piping the results to a file.&amp;nbsp; Why not just use a data step instead?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  infile 'bhosts' pipe;
  file "/home/test/%sysfunc(date(),yymmdd10).txt";
  input;
  _infile_=tranwrd(translate(_infile_,',',' '),'{2,}',',');
  put _infile_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 09 Feb 2020 02:47:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/X-Command-data-variable/m-p/623358#M19919</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-02-09T02:47:51Z</dc:date>
    </item>
    <item>
      <title>Re: X Command data variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/X-Command-data-variable/m-p/623381#M19924</link>
      <description>&lt;P&gt;+%F is a format qualifier that directs date to output a full format (YYYY-MM-DD).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think that the double quotes around the date call are a mistake, as are the double percent signs. When running this command from SAS, I'd let SAS compute the date.&lt;/P&gt;</description>
      <pubDate>Sun, 09 Feb 2020 08:07:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/X-Command-data-variable/m-p/623381#M19924</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-02-09T08:07:08Z</dc:date>
    </item>
    <item>
      <title>Re: X Command data variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/X-Command-data-variable/m-p/623382#M19925</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;X "bhosts | sed 's/ /,/g' | sed 's/,\{2,\}/,/g' &amp;gt; /home/test_%sysfunc(today(),yymmddd10.).txt";&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 09 Feb 2020 08:10:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/X-Command-data-variable/m-p/623382#M19925</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-02-09T08:10:34Z</dc:date>
    </item>
    <item>
      <title>Re: X Command data variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/X-Command-data-variable/m-p/623424#M19927</link>
      <description>&lt;P&gt;Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;.It was successful with your query. .&lt;/P&gt;</description>
      <pubDate>Sun, 09 Feb 2020 17:34:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/X-Command-data-variable/m-p/623424#M19927</guid>
      <dc:creator>helannivas88</dc:creator>
      <dc:date>2020-02-09T17:34:29Z</dc:date>
    </item>
  </channel>
</rss>

