<?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: Need help to create a file with TEXT strings and SAS dataset values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Need-help-to-create-a-file-with-TEXT-strings-and-SAS-dataset/m-p/844550#M333889</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/436884"&gt;@chatur&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thanks so much. This is very helpful.&lt;BR /&gt;&lt;BR /&gt;One follow up -&lt;BR /&gt;how would you write something like:&lt;BR /&gt;&lt;BR /&gt;Child's name is "John"&lt;BR /&gt;Child's age is 12&lt;BR /&gt;&lt;BR /&gt;(essentially, some data values need to be in quotes while others not)&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;To add quotes use the $QUOTE format.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;put 'Child''s name is ' name :$quote. 
  / 'Child''s age is ' age 
;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 16 Nov 2022 03:41:45 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-11-16T03:41:45Z</dc:date>
    <item>
      <title>Need help to create a file with TEXT strings and SAS dataset values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-to-create-a-file-with-TEXT-strings-and-SAS-dataset/m-p/844504#M333865</link>
      <description>&lt;P&gt;I need to create a text file that includes text strings concatenated with field values from SAS datasets.&lt;/P&gt;&lt;P&gt;For example, here is a file:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;My name is&lt;/FONT&gt;:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT color="#339966"&gt;John&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;Your name is:&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color="#339966"&gt;&amp;nbsp; Jack&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;We live in:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color="#339966"&gt;&amp;nbsp; California&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here&lt;FONT color="#FF0000"&gt; My name is:&lt;/FONT&gt; is a string&lt;/P&gt;&lt;P&gt;And&amp;nbsp;&lt;FONT color="#339966"&gt; John&lt;/FONT&gt; is a value of a field from a SAS dataset&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks to all who respond.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Nov 2022 21:44:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-to-create-a-file-with-TEXT-strings-and-SAS-dataset/m-p/844504#M333865</guid>
      <dc:creator>chatur</dc:creator>
      <dc:date>2022-11-15T21:44:42Z</dc:date>
    </item>
    <item>
      <title>Re: Need help to create a file with TEXT strings and SAS dataset values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-to-create-a-file-with-TEXT-strings-and-SAS-dataset/m-p/844508#M333867</link>
      <description>&lt;P&gt;A data step with PUT statements and a FILE statement to identify the output file name are one of the basic tools.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example:&lt;/P&gt;
&lt;PRE&gt;data _null_;
   set sashelp.class;
   file "c:\foldername\textfilename.txt";
   put "Child's name is " name;
   put "Child's gender is " sex;
   put "Child's age is " age;
run;&lt;/PRE&gt;
&lt;P&gt;You can test the output but using FILE PRINT; instead of an actual file name it the output will be directed to your Results window.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are options to control which column values appear such as @n where n is as column number, or + n to add n print positions to the output.&lt;/P&gt;
&lt;P&gt;Caution: text written this way will seldom align vertically unless you use a fixed width font such as Courier to view the file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Nov 2022 22:05:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-to-create-a-file-with-TEXT-strings-and-SAS-dataset/m-p/844508#M333867</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-11-15T22:05:52Z</dc:date>
    </item>
    <item>
      <title>Re: Need help to create a file with TEXT strings and SAS dataset values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-to-create-a-file-with-TEXT-strings-and-SAS-dataset/m-p/844512#M333869</link>
      <description>Take a look into PROC ODSTEXT as well.</description>
      <pubDate>Tue, 15 Nov 2022 22:10:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-to-create-a-file-with-TEXT-strings-and-SAS-dataset/m-p/844512#M333869</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-11-15T22:10:45Z</dc:date>
    </item>
    <item>
      <title>Re: Need help to create a file with TEXT strings and SAS dataset values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-to-create-a-file-with-TEXT-strings-and-SAS-dataset/m-p/844538#M333882</link>
      <description>Thanks so much. This is very helpful.&lt;BR /&gt;&lt;BR /&gt;One follow up -&lt;BR /&gt;how would you write something like:&lt;BR /&gt;&lt;BR /&gt;Child's name is "John"&lt;BR /&gt;Child's age is 12&lt;BR /&gt;&lt;BR /&gt;(essentially, some data values need to be in quotes while others not)&lt;BR /&gt;</description>
      <pubDate>Wed, 16 Nov 2022 00:40:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-to-create-a-file-with-TEXT-strings-and-SAS-dataset/m-p/844538#M333882</guid>
      <dc:creator>chatur</dc:creator>
      <dc:date>2022-11-16T00:40:42Z</dc:date>
    </item>
    <item>
      <title>Re: Need help to create a file with TEXT strings and SAS dataset values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-to-create-a-file-with-TEXT-strings-and-SAS-dataset/m-p/844539#M333883</link>
      <description>&lt;P&gt;thanks. i will check it out.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Nov 2022 00:40:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-to-create-a-file-with-TEXT-strings-and-SAS-dataset/m-p/844539#M333883</guid>
      <dc:creator>chatur</dc:creator>
      <dc:date>2022-11-16T00:40:57Z</dc:date>
    </item>
    <item>
      <title>Re: Need help to create a file with TEXT strings and SAS dataset values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-to-create-a-file-with-TEXT-strings-and-SAS-dataset/m-p/844549#M333888</link>
      <description>&lt;P&gt;To add quotes around the child's name, modify this statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;put "Child's name is " name;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Within a set of quotes, repeating the quote gets printed as a quote.&amp;nbsp; Yes, it sounds confusing, but it's easy once you try it:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;put "Child's name is """ name  +(-1) '"';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;With three quotes in a row ("""), the first two printed as a quote.&amp;nbsp; The third one ends the string.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The PUT statements leaves a blank after printing an unformatted variable (NAME).&amp;nbsp; So +(-1) moves the pointer back a space allowing the PUT statement to overwrite that blank.&amp;nbsp; Then '"' replaces the blank with a double quote.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Nov 2022 03:25:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-to-create-a-file-with-TEXT-strings-and-SAS-dataset/m-p/844549#M333888</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2022-11-16T03:25:47Z</dc:date>
    </item>
    <item>
      <title>Re: Need help to create a file with TEXT strings and SAS dataset values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-to-create-a-file-with-TEXT-strings-and-SAS-dataset/m-p/844550#M333889</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/436884"&gt;@chatur&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thanks so much. This is very helpful.&lt;BR /&gt;&lt;BR /&gt;One follow up -&lt;BR /&gt;how would you write something like:&lt;BR /&gt;&lt;BR /&gt;Child's name is "John"&lt;BR /&gt;Child's age is 12&lt;BR /&gt;&lt;BR /&gt;(essentially, some data values need to be in quotes while others not)&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;To add quotes use the $QUOTE format.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;put 'Child''s name is ' name :$quote. 
  / 'Child''s age is ' age 
;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Nov 2022 03:41:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-to-create-a-file-with-TEXT-strings-and-SAS-dataset/m-p/844550#M333889</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-11-16T03:41:45Z</dc:date>
    </item>
    <item>
      <title>Re: Need help to create a file with TEXT strings and SAS dataset values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-to-create-a-file-with-TEXT-strings-and-SAS-dataset/m-p/844662#M333927</link>
      <description>Thank you for your response. I was able to figure it out and that is also how I have structured it.</description>
      <pubDate>Wed, 16 Nov 2022 17:18:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-to-create-a-file-with-TEXT-strings-and-SAS-dataset/m-p/844662#M333927</guid>
      <dc:creator>chatur</dc:creator>
      <dc:date>2022-11-16T17:18:35Z</dc:date>
    </item>
    <item>
      <title>Re: Need help to create a file with TEXT strings and SAS dataset values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-to-create-a-file-with-TEXT-strings-and-SAS-dataset/m-p/844737#M333961</link>
      <description>Thank you!</description>
      <pubDate>Thu, 17 Nov 2022 01:34:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-to-create-a-file-with-TEXT-strings-and-SAS-dataset/m-p/844737#M333961</guid>
      <dc:creator>chatur</dc:creator>
      <dc:date>2022-11-17T01:34:55Z</dc:date>
    </item>
  </channel>
</rss>

