<?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: Problem with ARRAY in Mathematical Optimization, Discrete-Event Simulation, and OR</title>
    <link>https://communities.sas.com/t5/Mathematical-Optimization/Problem-with-ARRAY/m-p/6449#M127</link>
    <description>Faced with doing this for multiple variables, I would code it by arrays because I can.  But if you can't, then you may not have any confidence your solution is correct, and I would suggest you leave arrays alone.&lt;BR /&gt;
&lt;BR /&gt;
Instead, look up the Factual Material on the Transpose Procedure.  There are quite a few very well documented examples for rearranging rows of data into columns.&lt;BR /&gt;
&lt;BR /&gt;
As a hint, you will have to transpose once each for salary and staff count, and then match merge the results together.&lt;BR /&gt;
&lt;BR /&gt;
You might want to be very careful about your time line too.  I thought a trimester was a three part period, with the third trimester being the last.  That being so, I don't see how 2000 can have five trimesters.  Perhaps it is a mistake, but it is mistakes like that, which would kill your use of an array.&lt;BR /&gt;
&lt;BR /&gt;
Kind regards&lt;BR /&gt;
&lt;BR /&gt;
David</description>
    <pubDate>Mon, 21 Jan 2008 00:40:57 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2008-01-21T00:40:57Z</dc:date>
    <item>
      <title>Problem with ARRAY</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Problem-with-ARRAY/m-p/6448#M126</link>
      <description>Hi everybody! i'am new here, sorry if i am not very clear!&lt;BR /&gt;
I have a problem with ARRAY:&lt;BR /&gt;
i have data with firms identifiers, salaries and number of staff for each trimester of each year since 2000 to 2005.&lt;BR /&gt;
SO I want to create a new table wich gives to me a unique line for each firm and in each i would have the salary by  trimester per year (like 2000T1 2000T2 2000T3...2000T5) so i have to do this for the salary per trimester year and the number of staff per trimester year...&lt;BR /&gt;
But i cant use ARRAY AND RETAIN, &lt;BR /&gt;
if  anybody has an idea, i thanks him !</description>
      <pubDate>Sun, 20 Jan 2008 22:14:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Problem-with-ARRAY/m-p/6448#M126</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-01-20T22:14:23Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with ARRAY</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Problem-with-ARRAY/m-p/6449#M127</link>
      <description>Faced with doing this for multiple variables, I would code it by arrays because I can.  But if you can't, then you may not have any confidence your solution is correct, and I would suggest you leave arrays alone.&lt;BR /&gt;
&lt;BR /&gt;
Instead, look up the Factual Material on the Transpose Procedure.  There are quite a few very well documented examples for rearranging rows of data into columns.&lt;BR /&gt;
&lt;BR /&gt;
As a hint, you will have to transpose once each for salary and staff count, and then match merge the results together.&lt;BR /&gt;
&lt;BR /&gt;
You might want to be very careful about your time line too.  I thought a trimester was a three part period, with the third trimester being the last.  That being so, I don't see how 2000 can have five trimesters.  Perhaps it is a mistake, but it is mistakes like that, which would kill your use of an array.&lt;BR /&gt;
&lt;BR /&gt;
Kind regards&lt;BR /&gt;
&lt;BR /&gt;
David</description>
      <pubDate>Mon, 21 Jan 2008 00:40:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Problem-with-ARRAY/m-p/6449#M127</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-01-21T00:40:57Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with ARRAY</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Problem-with-ARRAY/m-p/6450#M128</link>
      <description>yes it was a mistake, i want to create variables trimester per year like that:&lt;BR /&gt;
2000T1  2000T2  2000T3 2000T4.....20005T4</description>
      <pubDate>Mon, 21 Jan 2008 09:03:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Problem-with-ARRAY/m-p/6450#M128</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-01-21T09:03:27Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with ARRAY</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Problem-with-ARRAY/m-p/6451#M129</link>
      <description>i post my email adress: if anybody could help me i'll give him my programme and i could send him what really i have to do!&lt;BR /&gt;
vascogil_1@hotmail.com</description>
      <pubDate>Mon, 21 Jan 2008 09:14:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Problem-with-ARRAY/m-p/6451#M129</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-01-21T09:14:05Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with ARRAY</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Problem-with-ARRAY/m-p/6452#M130</link>
      <description>hi&lt;BR /&gt;
can you be little more specific about your data structure like columns and rows or can u write sample dataset for which u want solution.&lt;BR /&gt;
                             because untill have an idia about data its not easy to give solution.                     &lt;BR /&gt;
                                     thanks</description>
      <pubDate>Mon, 21 Jan 2008 10:06:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Problem-with-ARRAY/m-p/6452#M130</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-01-21T10:06:54Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with ARRAY</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Problem-with-ARRAY/m-p/6453#M131</link>
      <description>it looks like that:&lt;BR /&gt;
the columns: variables:&lt;BR /&gt;
Ident/Salary/staff/year/trimester&lt;BR /&gt;
x1     /1200  /2     /2000/1&lt;BR /&gt;
x1   /2100  /4     /2000/2&lt;BR /&gt;
x1     /3440  /6     /2000/3&lt;BR /&gt;
...for each ident as x we have observations for salary and staff  per year trimester...&lt;BR /&gt;
until&lt;BR /&gt;
x1     /2300/ 6     /2005/4&lt;BR /&gt;
&lt;BR /&gt;
etc and we have many ident from x1 to Xn...&lt;BR /&gt;
&lt;BR /&gt;
so i want to create a new table which gives me&lt;BR /&gt;
Only one ident per line but all staff and salaries per each year trimester&lt;BR /&gt;
&lt;BR /&gt;
like:&lt;BR /&gt;
ident/salary_2000T1/salary_2000T2/.../salary_2005T4/staff_2000T1/staff_2000T2 etc...&lt;BR /&gt;
at least i have to create a new table with 4 trimesters per each of my 6 years but two times one for the staff an other for the salaries so 48 variables more ident and a anothre which doesnt matter.&lt;BR /&gt;
&lt;BR /&gt;
thats all!</description>
      <pubDate>Mon, 21 Jan 2008 21:21:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Problem-with-ARRAY/m-p/6453#M131</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-01-21T21:21:26Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with ARRAY</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Problem-with-ARRAY/m-p/6454#M132</link>
      <description>If you haven't installed the SAS Online documentation, then visit the web based documentation at  &lt;A href="http://support.sas.com/onlinedoc/913/docMainpage.jsp" target="_blank"&gt;http://support.sas.com/onlinedoc/913/docMainpage.jsp&lt;/A&gt;  and look up Base SAS / Transpose Procedure.&lt;BR /&gt;
&lt;BR /&gt;
Observe the example using the  BY statement  and how that relates to your IDENT variable.&lt;BR /&gt;
&lt;BR /&gt;
Now observe the  VAR statement  and how that relates to your SALARY and STAFF variables.&lt;BR /&gt;
&lt;BR /&gt;
Finally, observe that the ID statement will identify the variable that names the transposed columns.&lt;BR /&gt;
&lt;BR /&gt;
Note that the  PREFIX statement will identify the prefix to place before the value of your ID statement to name the column.  So, with a prefix value of  SAL  and an ID of  PERIOD  you will have columns named  SAL20001.  For naming purposes you are better off constructing a variable called PERIOD that concatenates  YEAR  and  "Trimester" into a value that does not contain characters you cannot use in variable naming.&lt;BR /&gt;
&lt;BR /&gt;
Do the transposition first for SALARY and then for  STAFF so that you can set the prefix appropriately for each  VAR  as you transpose it.&lt;BR /&gt;
&lt;BR /&gt;
Then match merge the two tables together to give you a single record for each Ident value.

Message was edited by: dkvj</description>
      <pubDate>Tue, 22 Jan 2008 04:20:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Problem-with-ARRAY/m-p/6454#M132</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-01-22T04:20:19Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with ARRAY</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Problem-with-ARRAY/m-p/6455#M133</link>
      <description>okay, i  understood the problem, but i have really to do this with ARRAY and RETAIN.&lt;BR /&gt;
I will try to TRANSPOSE the data table and i will see what it does. But i have to finish with array et retain!&lt;BR /&gt;
I think i have to use it because there are too many variables to create.&lt;BR /&gt;
&lt;BR /&gt;
They give to me this example, so i have to use it for my data...&lt;BR /&gt;
&lt;BR /&gt;
data MANYPER;&lt;BR /&gt;
	input ID TIME SCORE;&lt;BR /&gt;
	datalines;&lt;BR /&gt;
01	1	3&lt;BR /&gt;
01	2	4&lt;BR /&gt;
01	3	5&lt;BR /&gt;
02	1	7&lt;BR /&gt;
02	3	9&lt;BR /&gt;
03	1	6&lt;BR /&gt;
03	2	5&lt;BR /&gt;
03	3	4&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
proc sort data=MANYPER; by ID TIME; run;&lt;BR /&gt;
data ONEPER_REC;&lt;BR /&gt;
	array S[3] S1-S3;&lt;BR /&gt;
	retain S1-S3;&lt;BR /&gt;
	set MANYPER;&lt;BR /&gt;
	by ID;&lt;BR /&gt;
	If first.id then do i=1 to 3; &lt;BR /&gt;
		S&lt;I&gt; =.; &lt;BR /&gt;
	end;&lt;BR /&gt;
	S[TIME]=SCORE;&lt;BR /&gt;
	If last.id then output;&lt;BR /&gt;
	keep id S1-S3;&lt;BR /&gt;
run;&lt;/I&gt;</description>
      <pubDate>Tue, 22 Jan 2008 10:07:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Problem-with-ARRAY/m-p/6455#M133</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-01-22T10:07:57Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with ARRAY</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Problem-with-ARRAY/m-p/6456#M134</link>
      <description>the problem with that program is that mine have more conditions:&lt;BR /&gt;
i have trimesters (4) per years (6) and i have to build a data which gives me salary  and  the staff for every variable...&lt;BR /&gt;
i really dont know how to do...</description>
      <pubDate>Tue, 22 Jan 2008 10:10:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Problem-with-ARRAY/m-p/6456#M134</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-01-22T10:10:26Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with ARRAY</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Problem-with-ARRAY/m-p/6457#M135</link>
      <description>Try this solution which does not use array:&lt;BR /&gt;
&lt;BR /&gt;
data in;&lt;BR /&gt;
	infile cards dlm='/';&lt;BR /&gt;
	input Ident :$8. (Salary staff year trimester) (:8.);&lt;BR /&gt;
	Period = compress(Year||"T"||Trimester);&lt;BR /&gt;
cards;&lt;BR /&gt;
x1 /1200 /2 /2000/1&lt;BR /&gt;
x1 /2100 /4 /2000/2&lt;BR /&gt;
x1 /3440 /6 /2000/3&lt;BR /&gt;
x2 /1500 /1 /2000/1&lt;BR /&gt;
x2 /2900 /3 /2000/2&lt;BR /&gt;
x2 /3140 /5 /2000/3&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc sort data=in; by ident period; run;&lt;BR /&gt;
&lt;BR /&gt;
proc transpose data=in out=tmp1 (drop=_name_) prefix=salary_;&lt;BR /&gt;
	by ident;&lt;BR /&gt;
	id Period;&lt;BR /&gt;
	var salary;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc transpose data=in out=tmp2 (drop=_name_) prefix=staff_;&lt;BR /&gt;
	by ident;&lt;BR /&gt;
	id Period;&lt;BR /&gt;
	var staff;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data out;&lt;BR /&gt;
	merge tmp1 tmp2;&lt;BR /&gt;
	by ident;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
The output looks like this:&lt;BR /&gt;
&lt;BR /&gt;
Ident	salary_2000T1	salary_2000T2	salary_2000T3	staff_2000T1	staff_2000T2	staff_2000T3&lt;BR /&gt;
						&lt;BR /&gt;
x1	1200	2100	3440	2	4	6&lt;BR /&gt;
x2	1500	2900	3140	1	3	5</description>
      <pubDate>Tue, 22 Jan 2008 14:24:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Problem-with-ARRAY/m-p/6457#M135</guid>
      <dc:creator>1162</dc:creator>
      <dc:date>2008-01-22T14:24:09Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with ARRAY</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Problem-with-ARRAY/m-p/6458#M136</link>
      <description>Is this question related to Mathematical Optimization and Operations Research with SAS? If not, this is the wrong forum.</description>
      <pubDate>Tue, 22 Jan 2008 16:33:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Problem-with-ARRAY/m-p/6458#M136</guid>
      <dc:creator>Matthew_Galati</dc:creator>
      <dc:date>2008-01-22T16:33:30Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with ARRAY</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Problem-with-ARRAY/m-p/6459#M137</link>
      <description>Thank you so much for your help!&lt;BR /&gt;
It's a way to solve the problem, but my "boss" want I to do with array and retain!&lt;BR /&gt;
so if anybody knows, he or she is welcome!</description>
      <pubDate>Tue, 22 Jan 2008 17:11:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Problem-with-ARRAY/m-p/6459#M137</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-01-22T17:11:52Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with ARRAY</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Problem-with-ARRAY/m-p/6460#M138</link>
      <description>This the solution:&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data projet.etablissements5;&lt;BR /&gt;
	array salary[24] salary1-salary24; &lt;BR /&gt;
	array staff[24] staff1-staff24; &lt;BR /&gt;
	retain salary1-salary24&lt;BR /&gt;
		   staff1-staff24;&lt;BR /&gt;
	set projet.etablissements4;&lt;BR /&gt;
	by ident;&lt;BR /&gt;
	if first.ident then do i=1 to 24;&lt;BR /&gt;
		salary&lt;I&gt;=.;&lt;BR /&gt;
		staff&lt;I&gt;=.;&lt;BR /&gt;
	end;&lt;BR /&gt;
	salary[periode]=Masse_sal;&lt;BR /&gt;
	staff[periode]=Effectif;&lt;BR /&gt;
	if last.ident then output;&lt;BR /&gt;
	keep ident APE salary1-salary24 staff1-staff24;&lt;BR /&gt;
run;&lt;/I&gt;&lt;/I&gt;</description>
      <pubDate>Wed, 23 Jan 2008 19:56:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Problem-with-ARRAY/m-p/6460#M138</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-01-23T19:56:26Z</dc:date>
    </item>
  </channel>
</rss>

