<?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 ARRAY in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/ARRAY/m-p/871681#M344387</link>
    <description>&lt;P&gt;Hi there- I have 4 different terms as Q1, Q2, Q3&amp;nbsp; Q4,&amp;nbsp; for each subject .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID&amp;nbsp; &amp;nbsp; TERMS&lt;/P&gt;&lt;P&gt;id1&amp;nbsp; &amp;nbsp; &amp;nbsp;Q1&lt;/P&gt;&lt;P&gt;id1&amp;nbsp; &amp;nbsp; &amp;nbsp;Q1&lt;/P&gt;&lt;P&gt;id1&amp;nbsp; &amp;nbsp; &amp;nbsp;Q2&lt;/P&gt;&lt;P&gt;id1&amp;nbsp; &amp;nbsp; &amp;nbsp;Q3&lt;/P&gt;&lt;P&gt;id1&amp;nbsp; &amp;nbsp; &amp;nbsp;Q4&lt;/P&gt;&lt;P&gt;id1&amp;nbsp; &amp;nbsp; &amp;nbsp;Q4&lt;/P&gt;&lt;P&gt;id2&amp;nbsp; &amp;nbsp; &amp;nbsp;Q1&amp;nbsp;&lt;/P&gt;&lt;P&gt;id2&amp;nbsp; &amp;nbsp; &amp;nbsp;Q1&lt;/P&gt;&lt;P&gt;id2&amp;nbsp; &amp;nbsp; &amp;nbsp;Q2&lt;/P&gt;&lt;P&gt;id3&amp;nbsp; &amp;nbsp; &amp;nbsp;Q4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want them like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Id&amp;nbsp; &amp;nbsp; &amp;nbsp; Terms&lt;/P&gt;&lt;P&gt;id1&amp;nbsp; &amp;nbsp; &amp;nbsp;Q1&amp;nbsp; Q2&amp;nbsp; Q3&amp;nbsp; &amp;nbsp;Q4&lt;/P&gt;&lt;P&gt;id2&amp;nbsp; &amp;nbsp; &amp;nbsp;Q1&amp;nbsp; &amp;nbsp;Q2&lt;/P&gt;&lt;P&gt;id3&amp;nbsp; &amp;nbsp; &amp;nbsp;Q4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need a basic array code, here what I drafted does not give the output I need.&lt;/P&gt;&lt;P&gt;data new;&lt;/P&gt;&lt;P&gt;set old;&lt;/P&gt;&lt;P&gt;array T(4) TermsQ1-TermsQ4&lt;/P&gt;&lt;P&gt;Do i=1 to 4;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any advice? This is a simple array but the out put is not what I wanted.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 24 Apr 2023 17:51:24 GMT</pubDate>
    <dc:creator>emelergul</dc:creator>
    <dc:date>2023-04-24T17:51:24Z</dc:date>
    <item>
      <title>ARRAY</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ARRAY/m-p/871681#M344387</link>
      <description>&lt;P&gt;Hi there- I have 4 different terms as Q1, Q2, Q3&amp;nbsp; Q4,&amp;nbsp; for each subject .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID&amp;nbsp; &amp;nbsp; TERMS&lt;/P&gt;&lt;P&gt;id1&amp;nbsp; &amp;nbsp; &amp;nbsp;Q1&lt;/P&gt;&lt;P&gt;id1&amp;nbsp; &amp;nbsp; &amp;nbsp;Q1&lt;/P&gt;&lt;P&gt;id1&amp;nbsp; &amp;nbsp; &amp;nbsp;Q2&lt;/P&gt;&lt;P&gt;id1&amp;nbsp; &amp;nbsp; &amp;nbsp;Q3&lt;/P&gt;&lt;P&gt;id1&amp;nbsp; &amp;nbsp; &amp;nbsp;Q4&lt;/P&gt;&lt;P&gt;id1&amp;nbsp; &amp;nbsp; &amp;nbsp;Q4&lt;/P&gt;&lt;P&gt;id2&amp;nbsp; &amp;nbsp; &amp;nbsp;Q1&amp;nbsp;&lt;/P&gt;&lt;P&gt;id2&amp;nbsp; &amp;nbsp; &amp;nbsp;Q1&lt;/P&gt;&lt;P&gt;id2&amp;nbsp; &amp;nbsp; &amp;nbsp;Q2&lt;/P&gt;&lt;P&gt;id3&amp;nbsp; &amp;nbsp; &amp;nbsp;Q4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want them like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Id&amp;nbsp; &amp;nbsp; &amp;nbsp; Terms&lt;/P&gt;&lt;P&gt;id1&amp;nbsp; &amp;nbsp; &amp;nbsp;Q1&amp;nbsp; Q2&amp;nbsp; Q3&amp;nbsp; &amp;nbsp;Q4&lt;/P&gt;&lt;P&gt;id2&amp;nbsp; &amp;nbsp; &amp;nbsp;Q1&amp;nbsp; &amp;nbsp;Q2&lt;/P&gt;&lt;P&gt;id3&amp;nbsp; &amp;nbsp; &amp;nbsp;Q4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need a basic array code, here what I drafted does not give the output I need.&lt;/P&gt;&lt;P&gt;data new;&lt;/P&gt;&lt;P&gt;set old;&lt;/P&gt;&lt;P&gt;array T(4) TermsQ1-TermsQ4&lt;/P&gt;&lt;P&gt;Do i=1 to 4;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any advice? This is a simple array but the out put is not what I wanted.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2023 17:51:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ARRAY/m-p/871681#M344387</guid>
      <dc:creator>emelergul</dc:creator>
      <dc:date>2023-04-24T17:51:24Z</dc:date>
    </item>
    <item>
      <title>Re: ARRAY</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ARRAY/m-p/871684#M344390</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort
  data=have
  out=sorted
  nodupkey
;
by id terms;
run;

proc transpose
  data=sorted
  out=want (drop=_name_)
;
by id;
var terms;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Untested, posted from my tablet.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2023 18:04:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ARRAY/m-p/871684#M344390</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-04-24T18:04:49Z</dc:date>
    </item>
    <item>
      <title>Re: ARRAY</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ARRAY/m-p/871686#M344392</link>
      <description>&lt;P&gt;Before you can get an effective response to your question, you'll need to provide more information.&amp;nbsp; In particular&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Sample "data" ambiguity.&amp;nbsp; Your description of the current data layout suggests that ID1 and ID2 have two starting values for Q1 (and ID1 has two values for Q4).&amp;nbsp; Yet the desired output shows the ability to preserve only one value.&amp;nbsp; What do you want to do about such cases?&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;What is the current storage of your current "vertical" data.&amp;nbsp; Is it in a plain text file, or in a SAS data set?&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;If you provide actual sample data, it will be far easier to help.&amp;nbsp; Your initial data should have for each "row", an ID, a designation of which Q is specified, and the actual value for that ID/Q combination.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2023 18:11:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ARRAY/m-p/871686#M344392</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2023-04-24T18:11:30Z</dc:date>
    </item>
    <item>
      <title>Re: ARRAY</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ARRAY/m-p/871691#M344395</link>
      <description>&lt;P&gt;What do you want to do with duplicates?&amp;nbsp; Do you want to ignore them?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Where do you want the values to go?&amp;nbsp; If you want them to go into a variable with same name as the value then perhaps just use the LET option on PROC TRANSPOSE will work?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=have out=want let;
  by id;
  id term;
  var term;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Otherwise eliminate the duplicates first.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort nodupkey data=have out=for_transpose;
  by id term;
run;
proc transpose data=for_transpose prefix=Q out=want;
  by id;
  var term;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here is what the two different outputs look like:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_0-1682363434445.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/83105i65D44177D2CC7CD6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Tom_0-1682363434445.png" alt="Tom_0-1682363434445.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2023 19:10:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ARRAY/m-p/871691#M344395</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-04-24T19:10:43Z</dc:date>
    </item>
  </channel>
</rss>

