<?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: question about array coding in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/question-about-array-coding/m-p/430670#M106464</link>
    <description>&lt;P&gt;As you finalize your code, be sure to make the name of the array consistent.&lt;/P&gt;</description>
    <pubDate>Wed, 24 Jan 2018 20:43:55 GMT</pubDate>
    <dc:creator>ArtC</dc:creator>
    <dc:date>2018-01-24T20:43:55Z</dc:date>
    <item>
      <title>question about array coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/question-about-array-coding/m-p/430547#M106427</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using SAS 9.4 full edition. I have an array LM1-LM23 in which I'd like to find the most frequent field overall (in the test data below, it's "Done". The fields in the real data are character variables.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Case&amp;nbsp; LM1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; LM2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; LM3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;LM4....LM23&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Done&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Not done&amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Done&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Finishing&amp;nbsp; &amp;nbsp; Not Done&amp;nbsp;&amp;nbsp;Done&lt;/P&gt;&lt;P&gt;4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Done&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Started&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&lt;/P&gt;&lt;P&gt;5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Done&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Done&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Done&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Done&lt;/P&gt;&lt;P&gt;6&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Done&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Done&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Done&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Goal output&lt;/P&gt;&lt;P&gt;Done&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;11/15&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;Not Done&amp;nbsp; &amp;nbsp; &amp;nbsp;2/15&lt;/P&gt;&lt;P&gt;Finishing&amp;nbsp; &amp;nbsp; &amp;nbsp; 1/15&lt;/P&gt;&lt;P&gt;Started&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1/15&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Will this array coding only pull the first instance of the field?&amp;nbsp; Someone is getting&amp;nbsp;different&amp;nbsp;numbers from me so I don't think this array is coded correctly.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array Contrib [23] $ LM1-LM23;   
do p=1 to 23;
   if Contribution [p] &amp;gt; ' ' then do;
      factor = Contribution [p];
end; end;&lt;BR /&gt;&lt;BR /&gt;proc freq order=freq; tables factor; run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the help!&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jan 2018 17:08:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/question-about-array-coding/m-p/430547#M106427</guid>
      <dc:creator>lmyers2</dc:creator>
      <dc:date>2018-01-24T17:08:42Z</dc:date>
    </item>
    <item>
      <title>Re: question about array coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/question-about-array-coding/m-p/430555#M106432</link>
      <description>&lt;P&gt;While your program is very close, it's actually getting the last value (not the first).&amp;nbsp; You need to add this statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;output;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It goes right after assigning a value to FACTOR.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jan 2018 17:27:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/question-about-array-coding/m-p/430555#M106432</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-01-24T17:27:39Z</dc:date>
    </item>
    <item>
      <title>Re: question about array coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/question-about-array-coding/m-p/430558#M106434</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;&amp;nbsp;already answered your question. What you are trying to do is make a wide file long, and then analyze the resulting file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A group of us just wrote a paper and macro that does just that and you may find it useful if you have to do such tasks in the future. The still draft (but tested) macro and paper can be found at:&amp;nbsp;&lt;A href="http://www.sascommunity.org/wiki/An_Easier_and_Faster_Way_to_Untranspose_a_Wide_File" target="_blank"&gt;http://www.sascommunity.org/wiki/An_Easier_and_Faster_Way_to_Untranspose_a_Wide_File&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;After running the macro, the following code would accomplish the task:&lt;/P&gt;
&lt;PRE&gt;%untranspose(data=have, out=need (rename=(LM=factor)), var=LM, by=case,id=testnum)

proc freq order=freq;
  tables factor;
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jan 2018 17:35:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/question-about-array-coding/m-p/430558#M106434</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2018-01-24T17:35:35Z</dc:date>
    </item>
    <item>
      <title>Re: question about array coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/question-about-array-coding/m-p/430670#M106464</link>
      <description>&lt;P&gt;As you finalize your code, be sure to make the name of the array consistent.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jan 2018 20:43:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/question-about-array-coding/m-p/430670#M106464</guid>
      <dc:creator>ArtC</dc:creator>
      <dc:date>2018-01-24T20:43:55Z</dc:date>
    </item>
    <item>
      <title>Re: question about array coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/question-about-array-coding/m-p/430895#M106526</link>
      <description>&lt;P&gt;It is really easy for IML.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Case  LM1     &amp;amp; $       LM2   $       LM3    &amp;amp; $ LM4 $;   
cards;
1        Done           .                 .               .
2        Not done    .                  .               .
3        Done          Finishing    Not Done  Done
4        Done          Started           .              .
5        Done          Done         Done        Done
6        Done          Done          Done       .
;

proc iml;
use have(keep=lm:);
read all var _char_ into x;
close;
levels=t(setdif(unique(x),' ')); 
percent=j(nrow(levels),1);
total=sum(x^=' ');
do i=1 to nrow(levels);
  percent[i]=sum(x=levels[i])/total;
end;

create want var{levels percent};
append;
close;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Jan 2018 13:29:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/question-about-array-coding/m-p/430895#M106526</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-01-25T13:29:54Z</dc:date>
    </item>
    <item>
      <title>Re: question about array coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/question-about-array-coding/m-p/431054#M106575</link>
      <description>&lt;P&gt;That's very helpful - thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried naming the output (code below) but it doesn't come up as a separate data file. Does it result in a temporary file "contributing" that I can reference in future procs?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array ContribFactor [23] $ CF1-CF23;   
do p=1 to 23;
   if ContribFactor [p] &amp;gt; ' ' then do;
      factor = ContribFactor [p];
	  output=contributing;
end; end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Jan 2018 19:30:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/question-about-array-coding/m-p/431054#M106575</guid>
      <dc:creator>lmyers2</dc:creator>
      <dc:date>2018-01-25T19:30:21Z</dc:date>
    </item>
    <item>
      <title>Re: question about array coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/question-about-array-coding/m-p/431069#M106578</link>
      <description>&lt;P&gt;This code doesn't stand alone.&amp;nbsp; It needs to be part of a DATA step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The name on the DATA statement is the name of the SAS data set you are creating.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The name on the SET statement is the name of the SAS data set you are reading in.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Following the SET statement, add the rest of the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Following that, add a RUN statement.&amp;nbsp; (Don't forget to follow that with PROC FREQ.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Finally, the OUTPUT statement stands alone, as a one-word statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;output;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jan 2018 20:06:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/question-about-array-coding/m-p/431069#M106578</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-01-25T20:06:03Z</dc:date>
    </item>
    <item>
      <title>Re: question about array coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/question-about-array-coding/m-p/431276#M106645</link>
      <description>&lt;P&gt;Actually , it could be more simple.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Case  LM1     &amp;amp; $       LM2   $       LM3    &amp;amp; $ LM4 $;   
cards;
1        Done           .                 .               .
2        Not Done    .                  .               .
3        Done          Finishing    Not Done  Done
4        Done          Started           .              .
5        Done          Done         Done        Done
6        Done          Done          Done       .
;

proc iml;
use have;
read all var _char_ into x;
close;
call tabulate(level,freq,x);
percent=freq/countn(x);
level=t(level);
create want var {level percent};
append;
close;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 26 Jan 2018 14:18:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/question-about-array-coding/m-p/431276#M106645</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-01-26T14:18:51Z</dc:date>
    </item>
    <item>
      <title>Re: question about array coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/question-about-array-coding/m-p/431626#M106795</link>
      <description>&lt;P&gt;Yes - I have the array code within a data step with run at the end, along with a proc freq after that. Is there a way to make whatever output this creates into a datafile on its own and not the original finalfinalfile?&amp;nbsp; I want to keep the original file wide but make a new file that is long to answer one particular question. When I tried changing the set name to a new name, it gave me an error that said that file doesn't exist.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Laura&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data finalfinalfile; set finalfinalfile;
array ContribFactor [23] $ CF1-CF23;   
do p=1 to 23;
   if ContribFactor [p] &amp;gt; ' ' then do;
      factor = ContribFactor [p];
	  output;
end; end;
run;&lt;BR /&gt;&lt;BR /&gt;proc freq order=freq; tables factor / missing; run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 28 Jan 2018 19:46:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/question-about-array-coding/m-p/431626#M106795</guid>
      <dc:creator>lmyers2</dc:creator>
      <dc:date>2018-01-28T19:46:00Z</dc:date>
    </item>
    <item>
      <title>Re: question about array coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/question-about-array-coding/m-p/431627#M106796</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;When I tried changing the set name to a new name, it gave me an error that said that file doesn't exist.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The SET statement is where you tell what data to read in.&amp;nbsp; So of course it needs to exist.&lt;/P&gt;
&lt;P&gt;If you want to make a new data set then put the new name on the DATA statement as that is the one that defines the dataset(s) that you are creating.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 28 Jan 2018 20:02:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/question-about-array-coding/m-p/431627#M106796</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-01-28T20:02:16Z</dc:date>
    </item>
    <item>
      <title>Re: question about array coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/question-about-array-coding/m-p/431628#M106797</link>
      <description>&lt;P&gt;The DATA statement names the SAS data set you are creating.&amp;nbsp; So the DATA statement (not the SET statement) requires a new name, to hold the long version instead of the wide version.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However ... once you ran this step, it changed the wide data set, replacing it.&amp;nbsp; Do you still have access to the wide version in its original form?&lt;/P&gt;</description>
      <pubDate>Sun, 28 Jan 2018 20:49:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/question-about-array-coding/m-p/431628#M106797</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-01-28T20:49:40Z</dc:date>
    </item>
  </channel>
</rss>

