<?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 save a value of a variable in an exeternal file in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-save-a-value-of-a-variable-in-an-exeternal-file/m-p/103538#M21611</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If variable XXX comes from a dataset, you should refer to it (i.e. SET MYDATASET; ) . If it is a macro variable, you should assign it to a variable (i.e. XXX="&amp;amp;XXX"; put XXX; ) or use quotes in the put statement (i.e. put "&amp;amp;XXX"; )&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, 24 Aug 2012 13:37:12 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2012-08-24T13:37:12Z</dc:date>
    <item>
      <title>How to save a value of a variable in an exeternal file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-save-a-value-of-a-variable-in-an-exeternal-file/m-p/103537#M21610</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have the following need.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a varible XXX and I would save the value of this variable in an external file. If I do something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; file 'outup.txt';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; put XXX;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The file is empty and if I do this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; file 'outup.txt';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; put &amp;amp;XXX;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I get an error. Do there is a way to save the value of a variable in a file?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Aug 2012 13:12:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-save-a-value-of-a-variable-in-an-exeternal-file/m-p/103537#M21610</guid>
      <dc:creator>garag</dc:creator>
      <dc:date>2012-08-24T13:12:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to save a value of a variable in an exeternal file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-save-a-value-of-a-variable-in-an-exeternal-file/m-p/103538#M21611</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If variable XXX comes from a dataset, you should refer to it (i.e. SET MYDATASET; ) . If it is a macro variable, you should assign it to a variable (i.e. XXX="&amp;amp;XXX"; put XXX; ) or use quotes in the put statement (i.e. put "&amp;amp;XXX"; )&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, 24 Aug 2012 13:37:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-save-a-value-of-a-variable-in-an-exeternal-file/m-p/103538#M21611</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2012-08-24T13:37:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to save a value of a variable in an exeternal file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-save-a-value-of-a-variable-in-an-exeternal-file/m-p/103539#M21612</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi: As PG has explained, you must point to a SAS dataset in order to use a variable name in a PUT statement (unless you are creating the variable in your program).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The program below writes the NAME variable from SASHELP.CLASS to a flat file for only the students with an AGE that is GE 15.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;cynthia&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;data _null_;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&amp;nbsp; set sashelp.class;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&amp;nbsp; where age ge 15;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&amp;nbsp; file 'c:\temp\myflatfile.txt';&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&amp;nbsp; put name;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;Then if you open MYFLATFILE.TXT with Notepad, you will see the 5 students with ages greater than or equal to 15 in SASHELP.CLASS:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;Janet&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;Mary&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;Ronald&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;William&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;Philip&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Aug 2012 14:23:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-save-a-value-of-a-variable-in-an-exeternal-file/m-p/103539#M21612</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2012-08-24T14:23:49Z</dc:date>
    </item>
  </channel>
</rss>

