<?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 using &amp;amp; in creating data set in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/using-amp-in-creating-data-set/m-p/670261#M201173</link>
    <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;May anyone explain the following code?&lt;/P&gt;
&lt;P&gt;What is the using of symbol&amp;nbsp;&amp;amp; in the code?&lt;/P&gt;
&lt;P&gt;How many observations we should get ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data two;
input var1 $ var2 &amp;amp; $20.;
cards;
hope  sad and happy
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 18 Jul 2020 04:38:10 GMT</pubDate>
    <dc:creator>Ronein</dc:creator>
    <dc:date>2020-07-18T04:38:10Z</dc:date>
    <item>
      <title>using &amp; in creating data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-amp-in-creating-data-set/m-p/670261#M201173</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;May anyone explain the following code?&lt;/P&gt;
&lt;P&gt;What is the using of symbol&amp;nbsp;&amp;amp; in the code?&lt;/P&gt;
&lt;P&gt;How many observations we should get ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data two;
input var1 $ var2 &amp;amp; $20.;
cards;
hope  sad and happy
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 18 Jul 2020 04:38:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-amp-in-creating-data-set/m-p/670261#M201173</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2020-07-18T04:38:10Z</dc:date>
    </item>
    <item>
      <title>Re: using &amp; in creating data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-amp-in-creating-data-set/m-p/670265#M201174</link>
      <description>&lt;P&gt;Maxim 1: Read the&amp;nbsp;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lestmtsref&amp;amp;docsetTarget=n0lrz3gb7m9e4rn137op544ddg0v.htm&amp;amp;locale=en#p1amtoudf0eirbn1j8aofomln86x" target="_blank" rel="noopener"&gt;Documentation&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;Maxim 4: If in Doubt, Do a Test Run.&lt;/P&gt;</description>
      <pubDate>Sat, 18 Jul 2020 05:35:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-amp-in-creating-data-set/m-p/670265#M201174</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-07-18T05:35:42Z</dc:date>
    </item>
    <item>
      <title>Re: using &amp; in creating data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-amp-in-creating-data-set/m-p/670346#M201208</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;May anyone explain the following code?&lt;/P&gt;
&lt;P&gt;What is the using of symbol&amp;nbsp;&amp;amp; in the code?&lt;/P&gt;
&lt;P&gt;How many observations we should get ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data two;
input var1 $ var2 &amp;amp; $20.;
cards;
hope  sad and happy
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The purpose of the &amp;amp; in an INPUT statement is to force SAS to looks for two adjacent delimiters to find the end of the next "word" in the line when using LIST MODE input style.&amp;nbsp; It will also allow you to add an informat specification to your INPUT statement without forcing FORMATTED MODE input style.&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since the second "word" on the line does not have any places with multiple embedded spaces (space is the default delimiter) then for your example it does nothing.&amp;nbsp; If you had removed the &amp;amp; then SAS would have read VAR using FORMATTED MODE so it would have read the next 20 character, whether or not they contained any number of delimiters.&amp;nbsp; And since you are reading from in-line data the input is always padded to the next multiple of 80 characters the fact that 'sad and happy' is only 13 characters long would not have any impact.&amp;nbsp; But if you tried to read that line from a file stead and the line did not have at least 7 spaces after 'happy' then it would read past the end of the line and you would end up with zero observations.&amp;nbsp; So in that case the &amp;amp; would make a difference as it would prevent the $20. informat from attempting to read past the end of the line.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try this test program:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename test temp;
options parmcards=test;
parmcards;
123456789012345678901234567890
One   Two  Three  Four
sad and happy
;

data test1;
  infile test;
  input var1 &amp;amp; $20.;
  put var1 = $quote.;
run;

data test2;
  infile test;
  input var1  $20.;
  put var1 = $quote.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 18 Jul 2020 17:11:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-amp-in-creating-data-set/m-p/670346#M201208</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-07-18T17:11:24Z</dc:date>
    </item>
  </channel>
</rss>

