<?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: Creating an array from datalines. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-an-array-from-datalines/m-p/735123#M228996</link>
    <description>I would definitely use the shortcut, however, my professor requires arrays. I was just curious as the first block of code looks nothing like the second.</description>
    <pubDate>Sun, 18 Apr 2021 19:43:55 GMT</pubDate>
    <dc:creator>FrustratedBio</dc:creator>
    <dc:date>2021-04-18T19:43:55Z</dc:date>
    <item>
      <title>Creating an array from datalines.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-an-array-from-datalines/m-p/735115#M228994</link>
      <description>&lt;P&gt;I have to get this code into a frequncy table.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data Ques;&lt;BR /&gt;Input ID $ Reason1-Reason4;&lt;BR /&gt;Datalines;&lt;BR /&gt;001 3 6 13 17&lt;BR /&gt;002 8 3 4 .&lt;BR /&gt;003 20 2 . .&lt;BR /&gt;004 8 4 20 19&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code format I used and that my textbook suggested to do this goes like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data Ques;&lt;BR /&gt;Input ID $ Reason1-Reason4;&lt;BR /&gt;Datalines;&lt;BR /&gt;001 3 6 13 17&lt;BR /&gt;002 8 3 4 .&lt;BR /&gt;003 20 2 . .&lt;BR /&gt;004 8 4 20 19&lt;BR /&gt;;&lt;BR /&gt;Proc Sort Data=Ques;&lt;BR /&gt;by ID;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data Ques;&lt;BR /&gt;array count[4] Reason1-Reason4;&lt;BR /&gt;do Reason=1 to 4;&lt;BR /&gt;Dist=count[Reason];&lt;BR /&gt;Output;&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Proc Print Data=ques;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For some reason this doesn't seem to be working for me, and it returns a table full of missing values. The only difference I can perceive from my code and the book's code for the exact same problem is that their example contains a set statement referencing a example dataset.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Apr 2021 17:40:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-an-array-from-datalines/m-p/735115#M228994</guid>
      <dc:creator>FrustratedBio</dc:creator>
      <dc:date>2021-04-18T17:40:47Z</dc:date>
    </item>
    <item>
      <title>Re: Creating an array from datalines.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-an-array-from-datalines/m-p/735116#M228995</link>
      <description>&lt;P&gt;You left out the SET statement so the data step has no data to actually output.&lt;/P&gt;
&lt;P&gt;You will be better off if you don't overwrite the original data.&amp;nbsp; Use a different name on the DATA statement than on the SET statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ques_tall;
  set ques;
  array count[4] Reason1-Reason4;
  do Reason=1 to 4;
    Dist=count[Reason];
    output;
  end;
run;
proc print data=ques_tall;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can skip the ARRAY and the extra data step and just read the values into the "tall" structure to begin with.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ques_tall;
  input ID @;
  do Reason=1 to 4 ;
     input Dist @;
     output;
  end;
datalines;
001 3 6 13 17
002 8 3 4 .
003 20 2 . .
004 8 4 20 19
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 18 Apr 2021 17:49:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-an-array-from-datalines/m-p/735116#M228995</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-04-18T17:49:35Z</dc:date>
    </item>
    <item>
      <title>Re: Creating an array from datalines.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-an-array-from-datalines/m-p/735123#M228996</link>
      <description>I would definitely use the shortcut, however, my professor requires arrays. I was just curious as the first block of code looks nothing like the second.</description>
      <pubDate>Sun, 18 Apr 2021 19:43:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-an-array-from-datalines/m-p/735123#M228996</guid>
      <dc:creator>FrustratedBio</dc:creator>
      <dc:date>2021-04-18T19:43:55Z</dc:date>
    </item>
    <item>
      <title>Re: Creating an array from datalines.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-an-array-from-datalines/m-p/735124#M228997</link>
      <description>*runs* nothing like the second</description>
      <pubDate>Sun, 18 Apr 2021 19:44:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-an-array-from-datalines/m-p/735124#M228997</guid>
      <dc:creator>FrustratedBio</dc:creator>
      <dc:date>2021-04-18T19:44:18Z</dc:date>
    </item>
  </channel>
</rss>

