<?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 creating a two-dimensional array in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-creating-a-two-dimensional-array/m-p/373139#M276077</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/151986"&gt;@Amanda_Lemon&lt;/a&gt; wrote:&lt;BR /&gt;WOW, it works now! Yes, that was the problem. Thank you!&lt;BR /&gt;&lt;BR /&gt;Last quick question -- just to make sure I understand the syntax -- what does "if first.var5" exactly mean? What does SAS do when it sees this?&lt;BR /&gt;&lt;BR /&gt;Thank you again!&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Every time it encounters a new value of var5 that (first value of var5) in a group it increments the counter.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 05 Jul 2017 03:44:31 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-07-05T03:44:31Z</dc:date>
    <item>
      <title>Problem with creating a two-dimensional array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-creating-a-two-dimensional-array/m-p/372461#M276060</link>
      <description>&lt;P&gt;I am a beginning user&amp;nbsp;and have a problem with creating a two-dimensional array. Any advice would be highly appreciated. Thank you in advance.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a data set with 6 variables (ID and var1-var5) and 10 people. The data set is in Excel. I want to create a two-dimensional array (people by var), so I need a 10x5 array.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have no problem importing the data into SAS. It correctly displays the data table:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/10069iCA49B6BB97EDF11F/image-size/small?v=1.0&amp;amp;px=-1" border="0" alt="table.jpg" title="table.jpg" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But when I try to ask for a 10x5 array, this is what I get (goes on to ex50):&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/10071iBD9B3C99D0A992E1/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="table2.png" title="table2.png" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my syntax:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC IMPORT OUT = WORK.Example DATAFILE = "C:\Desktop\Example.xls"&lt;BR /&gt;DBMS = xls REPLACE;&lt;BR /&gt;SHEET = "Example";&lt;BR /&gt;GETNAMES = YES;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc print data = example;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data example;&lt;BR /&gt;array ex{10,2:6};&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc print;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the log:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1632 PROC IMPORT OUT = WORK.Example DATAFILE = "C:\Desktop\Example.xls"&lt;BR /&gt;1633 DBMS = xls REPLACE;&lt;BR /&gt;1634 SHEET = "Example";&lt;BR /&gt;1635 GETNAMES = YES;&lt;BR /&gt;1636 RUN;&lt;/P&gt;&lt;P&gt;NOTE: The import data set has 10 observations and 6 variables.&lt;BR /&gt;NOTE: WORK.EXAMPLE data set was successfully created.&lt;BR /&gt;NOTE: PROCEDURE IMPORT used (Total process time):&lt;BR /&gt;real time 0.01 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;1637 proc print data = example;&lt;BR /&gt;1638 run;&lt;/P&gt;&lt;P&gt;NOTE: There were 10 observations read from the data set WORK.EXAMPLE.&lt;BR /&gt;NOTE: PROCEDURE PRINT used (Total process time):&lt;BR /&gt;real time 0.07 seconds&lt;BR /&gt;cpu time 0.00 seconds&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;1639 data example;&lt;BR /&gt;1640 array ex{10,2:6};&lt;BR /&gt;1641 run;&lt;/P&gt;&lt;P&gt;NOTE: The data set WORK.EXAMPLE has 1 observations and 50 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.01 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;1642 proc print;&lt;BR /&gt;1643 run;&lt;/P&gt;&lt;P&gt;NOTE: There were 1 observations read from the data set WORK.EXAMPLE.&lt;BR /&gt;NOTE: PROCEDURE PRINT used (Total process time):&lt;BR /&gt;real time 0.07 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;</description>
      <pubDate>Sat, 01 Jul 2017 22:49:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-with-creating-a-two-dimensional-array/m-p/372461#M276060</guid>
      <dc:creator>Amanda_Lemon</dc:creator>
      <dc:date>2017-07-01T22:49:59Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with creating a two-dimensional array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-creating-a-two-dimensional-array/m-p/372466#M276061</link>
      <description>&lt;P&gt;It's easy to turn that into an array, but why do you want to do that? What are you trying to accomplish?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 01 Jul 2017 23:27:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-with-creating-a-two-dimensional-array/m-p/372466#M276061</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-07-01T23:27:58Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with creating a two-dimensional array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-creating-a-two-dimensional-array/m-p/372469#M276062</link>
      <description>Thank you for your prompt response. I need to be able to work with the cells.&lt;BR /&gt;&lt;BR /&gt;Specifically, I have a dataset of students' responses and corresponding teacher responses. The teacher responses, however, are not about a student but about a class. Some students were in the same class and thus have the same corresponding teacher responses. I want to identify class ID's by comparing teacher responses (if they are the same, the ID would be the same).&lt;BR /&gt;&lt;BR /&gt;I have a good idea how to accomplish that and already drafted a syntax using arrays. The problem is -- I can't turn the dataset into an array... Once I do that, I will be good to go.&lt;BR /&gt;&lt;BR /&gt;Thank you.</description>
      <pubDate>Sun, 02 Jul 2017 00:08:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-with-creating-a-two-dimensional-array/m-p/372469#M276062</guid>
      <dc:creator>Amanda_Lemon</dc:creator>
      <dc:date>2017-07-02T00:08:19Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with creating a two-dimensional array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-creating-a-two-dimensional-array/m-p/372473#M276063</link>
      <description>&lt;P&gt;That's the way an array looks in SAS (other than with SAS IML).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One can still process it as a mutlti-dimensional array, but there is probably a much easier way to do what you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What defines teacher in your data and what do you want your resulting data to look like?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, to answer your question, the first datastep below creates some test data, while the second loads that data into a 50x6 array. If you look at the resulting log (after you run the code), you'll see that all of the array elements can be seen and, if desired, processed. However, that is typically a very inefficient way to use SAS:&lt;/P&gt;
&lt;PRE&gt;data have (drop=j);
  input var1-var5;
  array vars(5) var1-var5;
  do id=1 to 50;
    if mod(id,2) then do;
      do j=1 to 5;
        vars(j)=vars(j)-1;
      end;
      output;
      do j=1 to 5;
        vars(j)=vars(j)+1;
      end;
    end;
    else output;
  end;
  cards;
2 3 4 5 2 3
;

data want;
  set have end=eof;
  array vars_in(5) var1-var5;
  array vars(50,6) _temporary_;
  vars(_n_,1)=id;
  do i=1 to 5;
    vars(_n_,i+1)=vars_in(i);
  end;
  if eof then do;
    do i=1 to 50;
      put vars(i,1)= vars(i,2)= vars(i,3)= vars(i,4)= vars(i,5)=;
    end;
  end;
run;
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;</description>
      <pubDate>Sun, 02 Jul 2017 00:40:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-with-creating-a-two-dimensional-array/m-p/372473#M276063</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-07-02T00:40:42Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with creating a two-dimensional array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-creating-a-two-dimensional-array/m-p/372478#M276064</link>
      <description>Hi:&lt;BR /&gt;  And for a good explanation of two-dimensional arrays and how the variables get created, please take at look at Example 4 starting on page 9 in this paper: &lt;A href="https://support.sas.com/rnd/papers/sgf07/arrays1780.pdf" target="_blank"&gt;https://support.sas.com/rnd/papers/sgf07/arrays1780.pdf&lt;/A&gt; &lt;BR /&gt;&lt;BR /&gt;The relevant information is at the top of page 9, where it says: "You can think of a two-dimensional array as having 'rows' and 'columns', but to SAS, a two-dimensional array is no different than a one-dimensional array. It is still an alias for data set variables in the PDV or for temporary data elements."&lt;BR /&gt;&lt;BR /&gt;  It's a good paper and sheds light on how you work with multi-dimension arrays.&lt;BR /&gt;&lt;BR /&gt;cynthia</description>
      <pubDate>Sun, 02 Jul 2017 01:34:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-with-creating-a-two-dimensional-array/m-p/372478#M276064</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2017-07-02T01:34:01Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with creating a two-dimensional array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-creating-a-two-dimensional-array/m-p/372484#M276065</link>
      <description>&lt;P&gt;You're going about this incorrectly. You don't need to use arrays here. I would strongly suggest posting sample data for what you're trying to do and someone can show you how to arange your data to obtain the results. It's best to use SAS 'way' of doing this rather than trying to fit it into another languages concepts. The array method is easier to think about because that's how we're taught math but it's not applicable here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To join by ID you would do a MERGE or JOIN on the two datasets and then you would be able to make your comparisons.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You probably can load your data into IML to work with it as a matrix but that's not how SAS processes data, it moves through the data line by line.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 02 Jul 2017 02:03:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-with-creating-a-two-dimensional-array/m-p/372484#M276065</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-02T02:03:14Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with creating a two-dimensional array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-creating-a-two-dimensional-array/m-p/372490#M276066</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your responses.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I feel that I am going in a wrong direction... Using the syntax of Art (thank you, Art!), I got this (goes on to 50):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/10074i3C0065AF0327F289/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="pic.jpg" title="pic.jpg" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And that's not exactly what I want -- I want a 10x5 array, not 10x50 -- I played around but couldn't get 10x5...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Reeza, I am attaching the sample data. So, I have 10 students. var1-var5 are teacher responses about the class a student was in. Some students were in the same classes. For students who were in the same classes, teacher responses are the same. Task: to identify class IDs (i.e., students in the same classes will have the same class IDs). I put the correct answer - the correct class IDs - in the sample data file attached, so that you know what result I am looking for.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How should I approach this?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;P.S. I learned Pascal years ago and the array method worked well there. Now I am trying to apply Pascal logic to SAS... but apparently it's not working... Maybe I should use a different programming language in which I can use the array method? Will R be suitable for that?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 02 Jul 2017 02:29:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-with-creating-a-two-dimensional-array/m-p/372490#M276066</guid>
      <dc:creator>Amanda_Lemon</dc:creator>
      <dc:date>2017-07-02T02:29:57Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with creating a two-dimensional array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-creating-a-two-dimensional-array/m-p/372491#M276067</link>
      <description>&lt;P&gt;You haven't said what you want to do with the data. Assigning class numbers is simple. I used the following code. My assigned numbers are different than yours, but follow the same pattern:&lt;/P&gt;
&lt;PRE&gt;proc import datafile='/folders/myfolders/example.xls' dbms=xls out=have replace;
run;

proc sort data=have out=want;
  by var1-var5;
run;

data want;
  set want;
  by var1-var5;
  if first.var5 then class+1;
run;
&lt;/PRE&gt;
&lt;P&gt;But, I can't answer your question of what language would be better without knowing what you are trying to accomplish. I also used to program in Pascal (and Fortran, Basic and many other languages). My guess is that you will find SAS to be a lot more powerful than any of them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 02 Jul 2017 02:48:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-with-creating-a-two-dimensional-array/m-p/372491#M276067</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-07-02T02:48:39Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with creating a two-dimensional array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-creating-a-two-dimensional-array/m-p/372492#M276068</link>
      <description>&lt;P&gt;At the end of the day, which language you use is entirely up to you. R is free so that's helpful for sure.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My issue with R is the many, many different packages and ways of doing things. If you're doing basic processing you shouldn't have too many issues in either languages. Both have many free resources online to teach you the languages.&lt;/P&gt;
&lt;P&gt;For SAS you can start here:&lt;/P&gt;
&lt;P&gt;support.sas.com/training/tutorial&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It has a free e-course, see bottom right hand corner, for the link.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I honestly can't recall if I worked with Pascal back in the day or not...I've played around with too many languages &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Response;
infile cards dlm='09'x;

input ID var1 var2 var3 var4 var5;
cards;
1	3	4	5	2	3
2	3	4	5	1	3
3	3	4	4	3	4
4	3	4	5	1	3
5	4	5	5	5	5
6	4	5	5	5	5
7	3	4	4	3	4
8	4	1	2	4	6
9	3	4	5	2	3
10	4	5	5	5	5
;
run;

*sort into order;
proc sort data=response;
by var1-var5;
run;

*Identify each new group of variables;
data want;
set response;

by var1 var2 var3 var4 var5; *specify how data is sorted;

if first.var5 then class+1; *identify unique groups;

run;

*print to display;
proc print data=want;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 02 Jul 2017 02:50:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-with-creating-a-two-dimensional-array/m-p/372492#M276068</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-02T02:50:26Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with creating a two-dimensional array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-creating-a-two-dimensional-array/m-p/372493#M276069</link>
      <description>&lt;P&gt;And sometimes you'll get answers that are the exact same seconds apart here.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm impressed, we even referenced the variables the same way&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13711"&gt;@art297&lt;/a&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 02 Jul 2017 02:51:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-with-creating-a-two-dimensional-array/m-p/372493#M276069</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-02T02:51:48Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with creating a two-dimensional array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-creating-a-two-dimensional-array/m-p/372541#M276070</link>
      <description>&lt;P&gt;You have some good answers on how to create groups of records that the share same set of values. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In terms of comparisons to other languages it is probably better to think of SAS in terms of relational databases. &amp;nbsp;Think of a SAS dataset not as a matrix but as a series of observations of a fixed number of variables. &amp;nbsp;In that case a two dimensional matrix is normally represented by three variables. One to store the actual value and one each for the row and column index.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am still not sure what your data represents or even what calculation you are trying to do. &amp;nbsp;It kind of looks like your first column is the student id, but I am not sure what your 5 variables represent. &amp;nbsp;Are they the responses of 5 teachers?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
  input student @;
  do teacher=1 to 5 ;
    input rating @;
    output;
  end;
cards;
1	3	4	5	2	3
2	3	4	5	1	3
3	3	4	4	3	4
4	3	4	5	1	3
5	4	5	5	5	5
6	4	5	5	5	5
7	3	4	4	3	4
8	4	1	2	4	6
9	3	4	5	2	3
10	4	5	5	5	5
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Or perhaps they represent the 5 classes that the student had and the values are the ids of the teacher of the class?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
  input student @;
  do class=1 to 5 ;
    input teacher @;
    output;
  end;
cards;
1	3	4	5	2	3
2	3	4	5	1	3
3	3	4	4	3	4
4	3	4	5	1	3
5	4	5	5	5	5
6	4	5	5	5	5
7	3	4	4	3	4
8	4	1	2	4	6
9	3	4	5	2	3
10	4	5	5	5	5
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 02 Jul 2017 13:57:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-with-creating-a-two-dimensional-array/m-p/372541#M276070</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-07-02T13:57:45Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with creating a two-dimensional array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-creating-a-two-dimensional-array/m-p/373114#M276071</link>
      <description>&lt;P&gt;Thank you all! Dear Reeza and Art, when running your script, I get this error in the log:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;81 data want;&lt;BR /&gt;82 set example;&lt;BR /&gt;83 by var1 var2 var3 var4 var5;&lt;BR /&gt;84 if first.var5 then class+1;&lt;BR /&gt;-&lt;BR /&gt;400&lt;BR /&gt;ERROR 400-185: The SUM statement requires numeric expression.&lt;/P&gt;&lt;P&gt;85 run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am sure there is a very easy fix to that but I can't figure out... Could you please help me with that? Thank you in advance.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2017 00:53:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-with-creating-a-two-dimensional-array/m-p/373114#M276071</guid>
      <dc:creator>Amanda_Lemon</dc:creator>
      <dc:date>2017-07-05T00:53:03Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with creating a two-dimensional array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-creating-a-two-dimensional-array/m-p/373115#M276072</link>
      <description>&lt;P&gt;As for my question about other languages, I guess to be more specific the question would be as follows: which programming language will allow me to convert a data set into a 2-dimensional array and then work easily with such an array?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2017 00:57:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-with-creating-a-two-dimensional-array/m-p/373115#M276072</guid>
      <dc:creator>Amanda_Lemon</dc:creator>
      <dc:date>2017-07-05T00:57:31Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with creating a two-dimensional array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-creating-a-two-dimensional-array/m-p/373116#M276073</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/151986"&gt;@Amanda_Lemon&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Thank you all! Dear Reeza and Art, when running your script, I get this error in the log:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;81 data want;&lt;BR /&gt;82 set example;&lt;BR /&gt;83 by var1 var2 var3 var4 var5;&lt;BR /&gt;84&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if first.var5 then classCount + 1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;-&lt;BR /&gt;400&lt;BR /&gt;ERROR 400-185: The SUM statement requires numeric expression.&lt;/P&gt;
&lt;P&gt;85 run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am sure there is a very easy fix to that but I can't figure out... Could you please help me with that? Thank you in advance.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I suspect you already have a variable called CLASS in your dataset which is a character variable. Pick any other variable name, that you don't have in your data set and change CLASS to that.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2017 01:25:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-with-creating-a-two-dimensional-array/m-p/373116#M276073</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-05T01:25:32Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with creating a two-dimensional array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-creating-a-two-dimensional-array/m-p/373117#M276074</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/151986"&gt;@Amanda_Lemon&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;As for my question about other languages, I guess to be more specific the question would be as follows: which programming language will allow me to convert a data set into a 2-dimensional array and then work easily with such an array?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Within SAS, IML will allow you to do that. But if you have character variables you'll also run into issues, because matrices/arrays are typically numeric. R dataframe will allow you to store mixed types. &amp;nbsp;Python and R are fairly similar when it comes to analysis.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2017 01:29:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-with-creating-a-two-dimensional-array/m-p/373117#M276074</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-05T01:29:29Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with creating a two-dimensional array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-creating-a-two-dimensional-array/m-p/373123#M276075</link>
      <description>WOW, it works now! Yes, that was the problem. Thank you!&lt;BR /&gt;&lt;BR /&gt;Last quick question -- just to make sure I understand the syntax -- what does "if first.var5" exactly mean? What does SAS do when it sees this?&lt;BR /&gt;&lt;BR /&gt;Thank you again!</description>
      <pubDate>Wed, 05 Jul 2017 02:03:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-with-creating-a-two-dimensional-array/m-p/373123#M276075</guid>
      <dc:creator>Amanda_Lemon</dc:creator>
      <dc:date>2017-07-05T02:03:14Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with creating a two-dimensional array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-creating-a-two-dimensional-array/m-p/373124#M276076</link>
      <description>I haven't thought about IML... Thank you, Reeza!&lt;BR /&gt;&lt;BR /&gt;Just to make sure I understand how it works -- do you mind showing how to convert a data set into a 2-dimensional matrix using IML?&lt;BR /&gt;&lt;BR /&gt;Thanks again!</description>
      <pubDate>Wed, 05 Jul 2017 02:07:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-with-creating-a-two-dimensional-array/m-p/373124#M276076</guid>
      <dc:creator>Amanda_Lemon</dc:creator>
      <dc:date>2017-07-05T02:07:11Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with creating a two-dimensional array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-creating-a-two-dimensional-array/m-p/373139#M276077</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/151986"&gt;@Amanda_Lemon&lt;/a&gt; wrote:&lt;BR /&gt;WOW, it works now! Yes, that was the problem. Thank you!&lt;BR /&gt;&lt;BR /&gt;Last quick question -- just to make sure I understand the syntax -- what does "if first.var5" exactly mean? What does SAS do when it sees this?&lt;BR /&gt;&lt;BR /&gt;Thank you again!&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Every time it encounters a new value of var5 that (first value of var5) in a group it increments the counter.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2017 03:44:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-with-creating-a-two-dimensional-array/m-p/373139#M276077</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-05T03:44:31Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with creating a two-dimensional array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-creating-a-two-dimensional-array/m-p/373140#M276078</link>
      <description>Wait, why is it var5 that has a new value? I thought it should be that if the whole set (var 1 through var 5) is new, then increment the counter... no?</description>
      <pubDate>Wed, 05 Jul 2017 03:50:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-with-creating-a-two-dimensional-array/m-p/373140#M276078</guid>
      <dc:creator>Amanda_Lemon</dc:creator>
      <dc:date>2017-07-05T03:50:52Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with creating a two-dimensional array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-creating-a-two-dimensional-array/m-p/373146#M276079</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/151986"&gt;@Amanda_Lemon&lt;/a&gt; wrote:&lt;BR /&gt;Wait, why is it var5 that has a new value? I thought it should be that if the whole set (var 1 through var 5) is new, then increment the counter... no?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The BY has all 5 listed so it's grouped within those variables. Since var5 is the last it uniquely identifies your groups.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ie If Var2 stays the same it may still be a new group.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BY group processing is incredibly powerful. It allows you to identify groups in your data for specific processing, so you can do the exact same thing for each BY group without loops. Run the following code as an example. You'll get a chart for each make.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc sort data=SASHELP.cars out=cars;
By make;
Run;

Proc SGPLOT data=cars;
By make;
Scatter x=mpg_city y=mpg_highway;
Run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 05 Jul 2017 04:32:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-with-creating-a-two-dimensional-array/m-p/373146#M276079</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-05T04:32:56Z</dc:date>
    </item>
  </channel>
</rss>

