<?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: Run SAS array when  array value is not consecutive in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Run-SAS-array-when-array-value-is-not-consecutive/m-p/669284#M200752</link>
    <description>&lt;P&gt;I have program that run the transpose job. Now I am seeking alternative way to have it done differently.&lt;/P&gt;</description>
    <pubDate>Tue, 14 Jul 2020 19:40:37 GMT</pubDate>
    <dc:creator>Petergao1</dc:creator>
    <dc:date>2020-07-14T19:40:37Z</dc:date>
    <item>
      <title>Run SAS array when  array value is not consecutive</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-SAS-array-when-array-value-is-not-consecutive/m-p/669270#M200747</link>
      <description>&lt;P&gt;Hi friends,&lt;/P&gt;&lt;P&gt;I have a question to ask. When one runs an array job, the array's&amp;nbsp;&lt;EM&gt;dimension-size&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;value must be consecutive, like from 5-9 (5,6,7,8,9). I have a data set for schools with subgroups. which is not consecutive. Its value is 1,4,5,6,7,8,9,13,14,25, in long format.&lt;/P&gt;&lt;P&gt;In order for the array to run,I have to create another&amp;nbsp; variable, called group, to re-assign value to be consecutive, like, 1,2,3,4,5,6,7,8,9,10, (when subgroup=1, group=1, subgroup=4, group=2, subgroup=5, group=3, etc. Otherwise my array won't run properly.&lt;/P&gt;&lt;P&gt;This program is to turn data file from long to wide, to control the output, to avoid using a transpose, which is done so in the below codes.&lt;/P&gt;&lt;P&gt;Problem: After my data set was processed, I have to rename my output columns back to subgroup values, which is additional work and tedious.&amp;nbsp;&lt;/P&gt;&lt;P&gt;My question: is there some way&amp;nbsp; that one can use original data' s value (nonconsecutive) to run an array and get the job done?&lt;/P&gt;&lt;P&gt;*Note I have a data step to create a new var (group) before I can run my data step with an array;&lt;/P&gt;&lt;P&gt;*Also the file is sorted by sch_id and group;&lt;/P&gt;&lt;P&gt;Here is my program that is tested and working:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA want_wide ; *create a new data file name to be in wide format;&lt;BR /&gt;SET have_long; *read in the existing data file in long format;&lt;BR /&gt;By sch_id ; *read in data by the order of&amp;nbsp; sch_id-original data each school has 10 rows (or less) of data;&lt;/P&gt;&lt;P&gt;KEEP sch_id EM_ELA_statusCY1 - EM_ELA_statusCY10; *keep output data's these column only;&lt;BR /&gt;RETAIN&amp;nbsp; sch_id EM_ELA_statusCY1 - EM_ELA_statusCY10 ; *keep output data's column in this order;&lt;/P&gt;&lt;P&gt;ARRAY emstatus (1:10) $ EM_ELA_statusCY1 - EM_ELA_statusCY10 ; *process data by group value, from 1 to 10;&lt;BR /&gt;*based on sh_id, do the data step by the order of&amp;nbsp; group id value;&lt;BR /&gt;IF first.sch_id THEN DO;&lt;BR /&gt;DO i = 1 to 10 ;&lt;BR /&gt;emstatus ( i ) = "" ; *output data is character type;&lt;BR /&gt;*array's order is based on i's value;&lt;BR /&gt;*above defaulted array index output to be missing (" "), when it has data,then it will be replaced;&lt;BR /&gt;END;*finish array execution;&lt;BR /&gt;END;* finish the data round beginning with sch_id do loop;&lt;BR /&gt;emstatus ( group ) = EM_ELA_statusCY ; *this is the column to be transposed;&lt;BR /&gt;* this will assign output new column name (EM subject=ELA) combined with group value for each new column;&lt;BR /&gt;IF last.sch_id THEN OUTPUT ;*when reached the last sch_id, output data;&lt;BR /&gt;RUN; *It worked,&amp;nbsp; got the output as desired-long data set become wide, one school per row with 10 new columns;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;* After this I have to rename the 10 columns back to the subgroup value, say&amp;nbsp;&lt;/P&gt;&lt;P&gt;EM_ELA_statusCY8=EM_ELA_statusCY13,&lt;/P&gt;&lt;P&gt;EM_ELA_statusCY9=&amp;nbsp;EM_ELA_statusCY14&lt;/P&gt;&lt;P&gt;EM_ELA_statusCY10=EM_ELA_statusCY25,etc.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;*Since I have 40 such columns, renaming them can be time consuming, the example only show 10 of them, there are three other sets of data, each set will produce 10 columns;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea to go around so I do not need to create a new group var, and after the job rename my output columns back to subgroups' value?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;Curious Peter&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jul 2020 19:05:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-SAS-array-when-array-value-is-not-consecutive/m-p/669270#M200747</guid>
      <dc:creator>Petergao1</dc:creator>
      <dc:date>2020-07-14T19:05:03Z</dc:date>
    </item>
    <item>
      <title>Re: Run SAS array when  array value is not consecutive</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-SAS-array-when-array-value-is-not-consecutive/m-p/669272#M200748</link>
      <description>Why not use TRANSPOSE instead of avoiding it?&lt;BR /&gt;&lt;BR /&gt;One of the key benefits of TRANSPOSE is the ID and IDLABEL statement which easily allow you to control the new variable names as well as the variable labels.</description>
      <pubDate>Tue, 14 Jul 2020 19:10:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-SAS-array-when-array-value-is-not-consecutive/m-p/669272#M200748</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-07-14T19:10:36Z</dc:date>
    </item>
    <item>
      <title>Re: Run SAS array when  array value is not consecutive</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-SAS-array-when-array-value-is-not-consecutive/m-p/669274#M200750</link>
      <description>&lt;P&gt;I like&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;'s suggestion.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Alternatively:&lt;/P&gt;
&lt;P&gt;If you have variables var1, var4, var5, var6, var7, var8, var9, var13, var14, var25, this should work (note the double-dash)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ARRAY emstatus $ var1--var25 ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Also, I haven't gone through your code in detail, but usually converting long to wide just makes your problem worse. Usually long data sets are much easier to handle and analyze.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jul 2020 19:19:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-SAS-array-when-array-value-is-not-consecutive/m-p/669274#M200750</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-07-14T19:19:54Z</dc:date>
    </item>
    <item>
      <title>Re: Run SAS array when  array value is not consecutive</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-SAS-array-when-array-value-is-not-consecutive/m-p/669284#M200752</link>
      <description>&lt;P&gt;I have program that run the transpose job. Now I am seeking alternative way to have it done differently.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jul 2020 19:40:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-SAS-array-when-array-value-is-not-consecutive/m-p/669284#M200752</guid>
      <dc:creator>Petergao1</dc:creator>
      <dc:date>2020-07-14T19:40:37Z</dc:date>
    </item>
    <item>
      <title>Re: Run SAS array when  array value is not consecutive</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-SAS-array-when-array-value-is-not-consecutive/m-p/669285#M200753</link>
      <description>&lt;P&gt;Thanks for the suggestion. My data is in long format and there is one column called subgroup with values of 1,4,5,6,7,8,9,13,14,25; another column is the Em ELA status. that is why&amp;nbsp; and where I encounter problem if I use the subgroup values as my array's dimension.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jul 2020 19:43:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-SAS-array-when-array-value-is-not-consecutive/m-p/669285#M200753</guid>
      <dc:creator>Petergao1</dc:creator>
      <dc:date>2020-07-14T19:43:44Z</dc:date>
    </item>
    <item>
      <title>Re: Run SAS array when  array value is not consecutive</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-SAS-array-when-array-value-is-not-consecutive/m-p/669286#M200754</link>
      <description>&lt;P&gt;Quite often it is a very good idea to provide example starting data, the desired output and the rules involved.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Transpose is likely an option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Some ideas:&lt;/P&gt;
&lt;P&gt;You have code like this to set all elements of an array to missing:&lt;/P&gt;
&lt;PRE&gt;DO i = 1 to 10 ;
emstatus ( i ) = "" ; *output data is character type;
*array's order is based on i's value;
*above defaulted array index output to be missing (" "), when it has data,then it will be replaced;
END;*finish array execution;&lt;/PRE&gt;
&lt;P&gt;The do loop is unneeded you can accomplish the exact same thing with:&lt;/P&gt;
&lt;PRE&gt;call missing( of emstatus(*));&lt;/PRE&gt;
&lt;P&gt;Call missing sets the values of all variables, and yes a mix of character and numeric is allowed, in the parentheses to missing for the variable type. You can process all elements of an array with the "of arrayname(*) " syntax.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One option might be to consider a custom custom format that would map your desired group values (still not quite sure why the word "group" is used ). Then you could use index values like&amp;nbsp; varname[ functname(indexvalue)] to get the "group" .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But likely the introduction of additional variables to create the needed names with the ID statement in Proc Transpose is going to much easier.&lt;/P&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jul 2020 19:48:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-SAS-array-when-array-value-is-not-consecutive/m-p/669286#M200754</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-07-14T19:48:06Z</dc:date>
    </item>
    <item>
      <title>Re: Run SAS array when  array value is not consecutive</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-SAS-array-when-array-value-is-not-consecutive/m-p/669291#M200755</link>
      <description>Another option is to ignore the missing indexes. Create all the variables, even the empty ones. At the end, do a check for variables that are entirely empty and drop them.</description>
      <pubDate>Tue, 14 Jul 2020 20:12:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-SAS-array-when-array-value-is-not-consecutive/m-p/669291#M200755</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-07-14T20:12:35Z</dc:date>
    </item>
    <item>
      <title>Re: Run SAS array when  array value is not consecutive</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-SAS-array-when-array-value-is-not-consecutive/m-p/669304#M200762</link>
      <description>&lt;P&gt;Thanks again for the suggestion. I don't mind the array will run a dimension from 1, 2,3,... till 25. And then I can drop those empty cases. But&amp;nbsp; I do not know how to do that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the data structure (I took the first one case) and the first status column to process it into wide format. Th out put will be one row for one school with additional 10 columns, each columns is a group's status for a subject, like ELA.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;sch_id&lt;/TD&gt;&lt;TD&gt;groupid&lt;/TD&gt;&lt;TD&gt;group&lt;/TD&gt;&lt;TD&gt;EM_ELA_StatusCY&lt;/TD&gt;&lt;TD&gt;EM_Math_StatusCY&lt;/TD&gt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6&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;TD&gt;GS:MP&lt;/TD&gt;&lt;TD&gt;GS:MP&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;13&lt;/TD&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;14&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;TD&gt;GS:WAA&lt;/TD&gt;&lt;TD&gt;GS:WAA&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;25&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jul 2020 20:52:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-SAS-array-when-array-value-is-not-consecutive/m-p/669304#M200762</guid>
      <dc:creator>Petergao1</dc:creator>
      <dc:date>2020-07-14T20:52:47Z</dc:date>
    </item>
    <item>
      <title>Re: Run SAS array when  array value is not consecutive</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-SAS-array-when-array-value-is-not-consecutive/m-p/669314#M200767</link>
      <description>If you do a quick search on dropping empty columns on here you'll find that it's a question that gets ask and answered at least once a month I'd guess.</description>
      <pubDate>Tue, 14 Jul 2020 21:31:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-SAS-array-when-array-value-is-not-consecutive/m-p/669314#M200767</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-07-14T21:31:33Z</dc:date>
    </item>
    <item>
      <title>Re: Run SAS array when  array value is not consecutive</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-SAS-array-when-array-value-is-not-consecutive/m-p/669316#M200768</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/335171"&gt;@Petergao1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks for the suggestion. My data is in long format and there is one column called subgroup with values of 1,4,5,6,7,8,9,13,14,25; another column is the Em ELA status. that is why&amp;nbsp; and where I encounter problem if I use the subgroup values as my array's dimension.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Everything you said points to not transposing the data, leaving it long instead of wide. But you'd have to tell us what analysis you are planning with this data to be sure.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, if you TRANSPOSE the data, there shouldn't be any problems using the "double-dash" method I showed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I'm not sure what your resistance is to either idea.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jul 2020 21:34:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-SAS-array-when-array-value-is-not-consecutive/m-p/669316#M200768</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-07-14T21:34:06Z</dc:date>
    </item>
    <item>
      <title>Re: Run SAS array when  array value is not consecutive</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-SAS-array-when-array-value-is-not-consecutive/m-p/669325#M200771</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;I have program that run the transpose job. Now I am seeking alternative way to have it done differently.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;Given that this seems like more of an academic/learning exercise.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jul 2020 22:07:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-SAS-array-when-array-value-is-not-consecutive/m-p/669325#M200771</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-07-14T22:07:29Z</dc:date>
    </item>
    <item>
      <title>Re: Run SAS array when  array value is not consecutive</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-SAS-array-when-array-value-is-not-consecutive/m-p/669330#M200775</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/335171"&gt;@Petergao1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks again for the suggestion. I don't mind the array will run a dimension from 1, 2,3,... till 25. And then I can drop those empty cases. But&amp;nbsp; I do not know how to do that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the data structure (I took the first one case) and the first status column to process it into wide format. Th out put will be one row for one school with additional 10 columns, each columns is a group's status for a subject, like ELA.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;sch_id&lt;/TD&gt;
&lt;TD&gt;groupid&lt;/TD&gt;
&lt;TD&gt;group&lt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
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Are all those dashes indicating missing data? I am not sure why you make things "wide" with missing data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe it is time to ask what this somewhat ugly data set is to be used for. And possibly where that particular structure originate?&lt;/P&gt;
&lt;P&gt;With the column heading you show in that source this starts to sound like a REPORT may be easier to make then a very ugly data set if the data is not used for further analysis.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jul 2020 22:27:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-SAS-array-when-array-value-is-not-consecutive/m-p/669330#M200775</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-07-14T22:27:25Z</dc:date>
    </item>
    <item>
      <title>Re: Run SAS array when  array value is not consecutive</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-SAS-array-when-array-value-is-not-consecutive/m-p/669373#M200795</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/335171"&gt;@Petergao1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have program that run the transpose job. Now I am seeking alternative way to have it done differently.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;PROC TRANSPOSE is the way to go for this. Don't waste brain cycles ín a futile attempt to reinvent the wheel. Use your time for more useful things.&lt;/P&gt;
&lt;P&gt;Just compare this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input sch_id $ subgroup EM_ELA_statusCY $;
datalines;
A 1 abc
A 13 def
A 14 ghi
A 22 xyz
;

proc transpose data=have out=want prefix=EM_ELA_statusCY;
by sch_id;
var EM_ELA_statusCY;
id subgroup;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;with your complicated array code, the need to convert the subgroups to a continuous series, and the re-translation from that. Which one of those codes will you want to maintain in the future?&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jul 2020 07:33:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-SAS-array-when-array-value-is-not-consecutive/m-p/669373#M200795</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-07-15T07:33:49Z</dc:date>
    </item>
    <item>
      <title>Re: Run SAS array when  array value is not consecutive</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-SAS-array-when-array-value-is-not-consecutive/m-p/669873#M201008</link>
      <description>&lt;P&gt;The data set is real life file with just the column names modified for simplicity.&lt;/P&gt;&lt;P&gt;Yesterday or earlier I discovered I can run my job using the array dimension 1:25 and do i=1 to 25 without any modification to my data structure, it will run even though the real variable is not consecutive and will produce all those columns, when the subgroups have no value their output columns will have all missing values. All I need to do is in the keep, retain line, I list only those columns that have a value on subgroups and where they should have data (some missing is considered to have data).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Previous my program won't run because I forget to define the output columns to be character ones.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA want_wide;&lt;/P&gt;&lt;P&gt;SET have_long;&lt;/P&gt;&lt;P&gt;BY sch_id;&lt;/P&gt;&lt;P&gt;KEEP sch_id&lt;/P&gt;&lt;P&gt;EM_ELA_status1 EM_ELA_status4-EM_ELA_status9 EM_ELA_status13-EM_ELA_status14 EM_ELA_status25&lt;/P&gt;&lt;P&gt;EM_Math_status1 EM_Math_status4-EM_Math_status9 EM_Math_status13-EM_Math_status14 EM_Math_status25&lt;/P&gt;&lt;P&gt;HS_ELA_status1 HS_ELA_status4-HS_ELA_status9 HS_ELA_status13-HS_ELA_status14 HS_ELA_status25&lt;/P&gt;&lt;P&gt;HS_Math_status1 HS_Math_status4-HS_Math_status9 HS_Math_status13-HS_Math_status14 HS_Math_status25;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;RETAIN sch_id&lt;/P&gt;&lt;P&gt;EM_ELA_status1 EM_ELA_status4-EM_ELA_status9 EM_ELA_status13-EM_ELA_status14 EM_ELA_status25&lt;/P&gt;&lt;P&gt;EM_Math_status1 EM_Math_status4-EM_Math_status9 EM_Math_status13-EM_Math_status14 EM_Math_status25&lt;/P&gt;&lt;P&gt;HS_ELA_status1 HS_ELA_status4-HS_ELA_status9 HS_ELA_status13-HS_ELA_status14 HS_ELA_status25&lt;/P&gt;&lt;P&gt;HS_Math_status1 HS_Math_status4-HS_Math_status9 HS_Math_status13-HS_Math_status14 HS_Math_status25;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ARRAY emela (1:25) $ EM_ELA_status1 - EM_ELA_status25 ;&lt;/P&gt;&lt;P&gt;ARRAY emmath (1:25) $ EM_Math_status1 - EM_Math_status25 ;&lt;/P&gt;&lt;P&gt;ARRAY hsela (1:25) $ HS_ELA_status1 - HS_ELA_status25 ;&lt;/P&gt;&lt;P&gt;ARRAY hsmath (1:25) $ HS_Math_status1 - HS_Math_status25 ;&lt;/P&gt;&lt;P&gt;IF first.sch_id THEN DO;&lt;/P&gt;&lt;P&gt;DO i = 1 to 25 ;&lt;/P&gt;&lt;P&gt;emela( i ) = "" ;&lt;/P&gt;&lt;P&gt;emmath (i) = "";&lt;/P&gt;&lt;P&gt;hsela( i ) = "" ;&lt;/P&gt;&lt;P&gt;hsmath (i) = "";&lt;/P&gt;&lt;P&gt;END;&lt;/P&gt;&lt;P&gt;END;&lt;/P&gt;&lt;P&gt;emela (groupid) = EM_ELA_status;&lt;/P&gt;&lt;P&gt;emmath (groupid) = EM_Math_status;&lt;/P&gt;&lt;P&gt;hsela (groupid) = HS_ELA_status;&lt;/P&gt;&lt;P&gt;hsmath (groupid) = HS_Math_status;&lt;/P&gt;&lt;P&gt;IF last.sch_id THEN OUTPUT ;&lt;/P&gt;&lt;P&gt;RUN; *WORKS WELL;&lt;/P&gt;&lt;P&gt;*advantages: have less codes and programs than using transpose approach (code);&lt;/P&gt;&lt;P&gt;*shortcoming: output columns name have subgroup's numeric values instead of subgroup names-this is required by business convention, therefore I have to do further work to modify those 40 column names ending with number (1,4,5,6,7,8,9,13,14,25) into group names such as "All_students, SWD, Native_Amer, etc. after the main part of EM_ELA_status;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jul 2020 12:52:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-SAS-array-when-array-value-is-not-consecutive/m-p/669873#M201008</guid>
      <dc:creator>Petergao1</dc:creator>
      <dc:date>2020-07-16T12:52:23Z</dc:date>
    </item>
    <item>
      <title>Re: Run SAS array when  array value is not consecutive</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-SAS-array-when-array-value-is-not-consecutive/m-p/669882#M201014</link>
      <description>&lt;P&gt;I wished I can do that. I am new to this group and like to see your previous example or answers. Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jul 2020 13:44:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-SAS-array-when-array-value-is-not-consecutive/m-p/669882#M201014</guid>
      <dc:creator>Petergao1</dc:creator>
      <dc:date>2020-07-16T13:44:38Z</dc:date>
    </item>
    <item>
      <title>Re: Run SAS array when  array value is not consecutive</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-SAS-array-when-array-value-is-not-consecutive/m-p/669910#M201027</link>
      <description>&lt;P&gt;Make your data taller (longer) first&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=have_long out=long_long ;
  by sch_id groupid;
  var EM_ELA_status EM_Math_status HS_ELA_status HS_Math_status;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and then run PROC TRANSPOSE.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=long_long out=want_wide(drop=_name_) ;
   by sch_id;
   var col1;
   id _name_ groupid;
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>Thu, 16 Jul 2020 15:48:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-SAS-array-when-array-value-is-not-consecutive/m-p/669910#M201027</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-07-16T15:48:51Z</dc:date>
    </item>
    <item>
      <title>Re: Run SAS array when  array value is not consecutive</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-SAS-array-when-array-value-is-not-consecutive/m-p/669928#M201043</link>
      <description>&lt;P&gt;Learning how to search is worth the time.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Search terms used in the giant 'Find your SAS answers' above:&lt;/P&gt;
&lt;P&gt;"delete variable missing"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/forums/searchpage/tab/message?advanced=false&amp;amp;allow_punctuation=false&amp;amp;q=delete%20variable%20missing" target="_blank"&gt;https://communities.sas.com/t5/forums/searchpage/tab/message?advanced=false&amp;amp;allow_punctuation=false&amp;amp;q=delete%20variable%20missing&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/335171"&gt;@Petergao1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I wished I can do that. I am new to this group and like to see your previous example or answers. Thanks!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jul 2020 17:04:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-SAS-array-when-array-value-is-not-consecutive/m-p/669928#M201043</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-07-16T17:04:00Z</dc:date>
    </item>
  </channel>
</rss>

