<?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: How to do trasition matrix of data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-do-trasition-matrix-of-data/m-p/685044#M207710</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/347699"&gt;@y658li&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Here is the error message:&lt;/P&gt;
&lt;P&gt;do n=1 to dim(t);&lt;/P&gt;
&lt;P&gt;_&lt;/P&gt;
&lt;P&gt;133&lt;/P&gt;
&lt;P&gt;ERROR: The DIM, LBOUND, and HBOUND functions require an array name for the first argument.&lt;/P&gt;
&lt;P&gt;32 number=t(n);&lt;/P&gt;
&lt;P&gt;_&lt;/P&gt;
&lt;P&gt;68&lt;/P&gt;
&lt;P&gt;ERROR 124-185: The variable t has already been defined.&lt;/P&gt;
&lt;P&gt;ERROR 133-185: A loop variable cannot be an array name or a character variable; It must be a scalar numeric.&lt;/P&gt;
&lt;P&gt;ERROR 68-185: The function T is unknown, or cannot be accessed.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;When you get an error &lt;STRONG&gt;include the entire data step or proc code with ALL of the code and messages&lt;/STRONG&gt;. Copy from the log and paste into a code box opened on the forum with the &amp;lt;/&amp;gt; icon so the diagnostic character positions do not get moved and actually are useful.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The error from the DIM function means that you did not include an ARRAY definition for the array T prior to use, or attempted to use an array name that already has a variable of that name in the data.&lt;/P&gt;</description>
    <pubDate>Fri, 18 Sep 2020 17:22:00 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2020-09-18T17:22:00Z</dc:date>
    <item>
      <title>How to do trasition matrix of data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-do-trasition-matrix-of-data/m-p/684981#M207683</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a table looks like this:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Segment&lt;/TD&gt;&lt;TD&gt;actual_year&lt;/TD&gt;&lt;TD&gt;actual_quart&lt;/TD&gt;&lt;TD&gt;q1&lt;/TD&gt;&lt;TD&gt;q2&lt;/TD&gt;&lt;TD&gt;q3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;I-1&lt;/TD&gt;&lt;TD&gt;2020&lt;/TD&gt;&lt;TD&gt;Q2&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;I-2&lt;/TD&gt;&lt;TD&gt;2020&lt;/TD&gt;&lt;TD&gt;Q2&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;I-3&lt;/TD&gt;&lt;TD&gt;2020&lt;/TD&gt;&lt;TD&gt;Q2&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I want to know how to transform the table and make it looks like this:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Segment&lt;/TD&gt;&lt;TD&gt;scenario date&lt;/TD&gt;&lt;TD&gt;number&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;I-1&lt;/TD&gt;&lt;TD&gt;2020Q3&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;I-2&lt;/TD&gt;&lt;TD&gt;2020Q3&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;I-3&lt;/TD&gt;&lt;TD&gt;2020Q3&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;I-1&lt;/TD&gt;&lt;TD&gt;2020Q4&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;I-2&lt;/TD&gt;&lt;TD&gt;2020Q4&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;I-3&lt;/TD&gt;&lt;TD&gt;2020Q4&lt;/TD&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;I-1&lt;/TD&gt;&lt;TD&gt;2021Q1&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;I-2&lt;/TD&gt;&lt;TD&gt;2021Q1&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;I-3&lt;/TD&gt;&lt;TD&gt;2021Q1&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My question is, how to fix the column A (segment), but keep rotating the column D E F ...... (till the end of column Z) ? In addition, I also have an indicator which 2020Q2, each time I rotate the matrix, I need to add 1 quarter in the scenario date column. For example, the first scenario date is 2020Q3 and in row 4, it changes to 2020Q4...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much!&lt;/P&gt;&lt;P&gt;Lydia&lt;/P&gt;</description>
      <pubDate>Fri, 18 Sep 2020 14:22:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-do-trasition-matrix-of-data/m-p/684981#M207683</guid>
      <dc:creator>y658li</dc:creator>
      <dc:date>2020-09-18T14:22:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to do trasition matrix of data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-do-trasition-matrix-of-data/m-p/685001#M207694</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input Segment $	actual_year	actual_quart :$2.	q1	q2	q3;
cards;
I-1	2020	Q2	1	2	3
I-2	2020	Q2	4	5	6
I-3	2020	Q2	7	8	9
;

data want;
 if 0 then set have(keep=segment);
 scenario_date=.;
 set have;
 _n_=input(cats(actual_year,actual_quart),yyq6.);
 array t q1-q3;
 do n=1 to dim(t);
  scenario_date=intnx('qtr',_n_,n);
  number=t(n);
  output;
 end;
 drop q1-q3 actual_year actual_quart;
 format scenario_date yyq6.;
run;
  
proc sort data=want out=final_want(drop=n);
 by n;
run;

proc print  noobs data=final_want;run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 18 Sep 2020 15:18:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-do-trasition-matrix-of-data/m-p/685001#M207694</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-09-18T15:18:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to do trasition matrix of data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-do-trasition-matrix-of-data/m-p/685017#M207699</link>
      <description>&lt;P&gt;Here is the error message:&lt;/P&gt;&lt;P&gt;do n=1 to dim(t);&lt;/P&gt;&lt;P&gt;_&lt;/P&gt;&lt;P&gt;133&lt;/P&gt;&lt;P&gt;ERROR: The DIM, LBOUND, and HBOUND functions require an array name for the first argument.&lt;/P&gt;&lt;P&gt;32 number=t(n);&lt;/P&gt;&lt;P&gt;_&lt;/P&gt;&lt;P&gt;68&lt;/P&gt;&lt;P&gt;ERROR 124-185: The variable t has already been defined.&lt;/P&gt;&lt;P&gt;ERROR 133-185: A loop variable cannot be an array name or a character variable; It must be a scalar numeric.&lt;/P&gt;&lt;P&gt;ERROR 68-185: The function T is unknown, or cannot be accessed.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Sep 2020 16:00:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-do-trasition-matrix-of-data/m-p/685017#M207699</guid>
      <dc:creator>y658li</dc:creator>
      <dc:date>2020-09-18T16:00:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to do trasition matrix of data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-do-trasition-matrix-of-data/m-p/685026#M207701</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/347699"&gt;@y658li&lt;/a&gt;&amp;nbsp; Are you sure you posted a "representative mock sample" of your real? Are you cognizant of the variables in the dataset. Here is the log of the test results of the code I posted-&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

data have;
input Segment $	actual_year	actual_quart :$2.	q1	q2	q3;
cards;
I-1	2020	Q2	1	2	3
I-2	2020	Q2	4	5	6
I-3	2020	Q2	7	8	9
;

data want;
 if 0 then set have(keep=segment);
 scenario_date=.;
 set have;
 _n_=input(cats(actual_year,actual_quart),yyq6.);
 array t q1-q3;
 do n=1 to dim(t);
  scenario_date=intnx('qtr',_n_,n);
  number=t(n);
  output;
 end;
 drop q1-q3 actual_year actual_quart;
 format scenario_date yyq6.;
run;
  
proc sort data=want out=final_want(drop=n);
 by n;
run;

proc print  noobs data=final_want;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;LOG:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;7176  data have;
7177  input Segment $ actual_year actual_quart :$2.   q1  q2  q3;
7178  cards;

NOTE: The data set WORK.HAVE has 3 observations and 6 variables.
NOTE: DATA statement used (Total process time):
      real time           0.02 seconds
      cpu time            0.01 seconds


7182  ;
7183
7184  data want;
7185   if 0 then set have(keep=segment);
7186   scenario_date=.;
7187   set have;
7188   _n_=input(cats(actual_year,actual_quart),yyq6.);
7189   array t q1-q3;
7190   do n=1 to dim(t);
7191    scenario_date=intnx('qtr',_n_,n);
7192    number=t(n);
7193    output;
7194   end;
7195   drop q1-q3 actual_year actual_quart;
7196   format scenario_date yyq6.;
7197  run;

NOTE: There were 3 observations read from the data set WORK.HAVE.
NOTE: The data set WORK.WANT has 9 observations and 4 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.03 seconds


7198
7199  proc sort data=want out=final_want(drop=n);
7200   by n;
7201  run;

NOTE: There were 9 observations read from the data set WORK.WANT.
NOTE: The data set WORK.FINAL_WANT has 9 observations and 3 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds


7202
7203  proc print  noobs data=final_want;run;

NOTE: There were 9 observations read from the data set WORK.FINAL_WANT.
NOTE: PROCEDURE PRINT used (Total process time):
      real time           0.09 seconds
      cpu time            0.00 seconds

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;OUTPUT;&lt;/P&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.FINAL_WANT" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="l header" scope="col"&gt;Segment&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;scenario_date&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;number&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;I-1&lt;/TD&gt;
&lt;TD class="r data"&gt;2020Q3&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;I-2&lt;/TD&gt;
&lt;TD class="r data"&gt;2020Q3&lt;/TD&gt;
&lt;TD class="r data"&gt;4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;I-3&lt;/TD&gt;
&lt;TD class="r data"&gt;2020Q3&lt;/TD&gt;
&lt;TD class="r data"&gt;7&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;I-1&lt;/TD&gt;
&lt;TD class="r data"&gt;2020Q4&lt;/TD&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;I-2&lt;/TD&gt;
&lt;TD class="r data"&gt;2020Q4&lt;/TD&gt;
&lt;TD class="r data"&gt;5&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;I-3&lt;/TD&gt;
&lt;TD class="r data"&gt;2020Q4&lt;/TD&gt;
&lt;TD class="r data"&gt;8&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;I-1&lt;/TD&gt;
&lt;TD class="r data"&gt;2021Q1&lt;/TD&gt;
&lt;TD class="r data"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;I-2&lt;/TD&gt;
&lt;TD class="r data"&gt;2021Q1&lt;/TD&gt;
&lt;TD class="r data"&gt;6&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;I-3&lt;/TD&gt;
&lt;TD class="r data"&gt;2021Q1&lt;/TD&gt;
&lt;TD class="r data"&gt;9&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Fri, 18 Sep 2020 16:14:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-do-trasition-matrix-of-data/m-p/685026#M207701</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-09-18T16:14:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to do trasition matrix of data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-do-trasition-matrix-of-data/m-p/685044#M207710</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/347699"&gt;@y658li&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Here is the error message:&lt;/P&gt;
&lt;P&gt;do n=1 to dim(t);&lt;/P&gt;
&lt;P&gt;_&lt;/P&gt;
&lt;P&gt;133&lt;/P&gt;
&lt;P&gt;ERROR: The DIM, LBOUND, and HBOUND functions require an array name for the first argument.&lt;/P&gt;
&lt;P&gt;32 number=t(n);&lt;/P&gt;
&lt;P&gt;_&lt;/P&gt;
&lt;P&gt;68&lt;/P&gt;
&lt;P&gt;ERROR 124-185: The variable t has already been defined.&lt;/P&gt;
&lt;P&gt;ERROR 133-185: A loop variable cannot be an array name or a character variable; It must be a scalar numeric.&lt;/P&gt;
&lt;P&gt;ERROR 68-185: The function T is unknown, or cannot be accessed.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;When you get an error &lt;STRONG&gt;include the entire data step or proc code with ALL of the code and messages&lt;/STRONG&gt;. Copy from the log and paste into a code box opened on the forum with the &amp;lt;/&amp;gt; icon so the diagnostic character positions do not get moved and actually are useful.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The error from the DIM function means that you did not include an ARRAY definition for the array T prior to use, or attempted to use an array name that already has a variable of that name in the data.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Sep 2020 17:22:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-do-trasition-matrix-of-data/m-p/685044#M207710</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-09-18T17:22:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to do trasition matrix of data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-do-trasition-matrix-of-data/m-p/685049#M207711</link>
      <description>&lt;P&gt;ERROR 133-185: A loop variable cannot be an array name or a character variable; It must be a scalar numeric.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi this is my code:&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="1" color="#000080"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt; new_table;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="1" color="#0000ff"&gt;if&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT face="Courier New" size="1" color="#008080"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT face="Courier New" size="1" color="#0000ff"&gt;then&lt;/FONT&gt; &lt;FONT face="Courier New" size="1" color="#0000ff"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt; CORP_CCAR_RESUBMIT(keep=Segment);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="1"&gt;scenario_date=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="1" color="#008080"&gt;.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="1"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="1" color="#0000ff"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt; CORP_CCAR_RESUBMIT;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="1"&gt;_n_=input(cats(actual_year,actual_quarter),&lt;/FONT&gt;&lt;FONT face="Courier New" size="1" color="#008080"&gt;yyq6.&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="1" color="#0000ff"&gt;array&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt; time Q1-Q20;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="1" color="#0000ff"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt; i=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="1" color="#008080"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT face="Courier New" size="1" color="#0000ff"&gt;to&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt; dim(time);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="1"&gt;scenario_date=intnx(&lt;/FONT&gt;&lt;FONT face="Courier New" size="1" color="#800080"&gt;'qtr'&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt;,_n_,i);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;number=time(i);&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="1" color="#0000ff"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="1" color="#0000ff"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="1" color="#0000ff"&gt;drop&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt; Q1-Q20 actual_year actual_quarter;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="1" color="#0000ff"&gt;format&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt; scenario_date &lt;/FONT&gt;&lt;FONT face="Courier New" size="1" color="#008080"&gt;yyq6.&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="1" color="#000080"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="1"&gt;and this is my log:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;127 do i=1 to dim(time);&lt;/P&gt;&lt;P&gt;_&lt;/P&gt;&lt;P&gt;133&lt;/P&gt;&lt;P&gt;NOTE: The array time has the same name as a SAS-supplied or user-defined function. Parentheses following this name are treated as array references and not function references.&lt;/P&gt;&lt;P&gt;ERROR 133-185: A loop variable cannot be an array name or a character variable; It must be a scalar numeric.&lt;/P&gt;&lt;P&gt;NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).&lt;/P&gt;&lt;P&gt;127:7&lt;/P&gt;&lt;P&gt;NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).&lt;/P&gt;&lt;P&gt;128:33 129:15&lt;/P&gt;&lt;P&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;/P&gt;&lt;P&gt;WARNING: The data set WORK.NEW_TABLE may be incomplete. When this step was stopped there were 0 observations and 26 variables.&lt;/P&gt;&lt;P&gt;WARNING: Data set WORK.NEW_TABLE was not replaced because this step was stopped.&lt;/P&gt;&lt;P&gt;NOTE: DATA statement used (Total process time):&lt;/P&gt;&lt;P&gt;real time 0.00 seconds&lt;/P&gt;&lt;P&gt;user cpu time 0.00 seconds&lt;/P&gt;&lt;P&gt;system cpu time 0.00 seconds&lt;/P&gt;&lt;P&gt;memory 435.40k&lt;/P&gt;&lt;P&gt;OS Memory 28844.00k&lt;/P&gt;&lt;P&gt;Timestamp 2020-09-18 01:43:05 PM&lt;/P&gt;&lt;P&gt;Step Count 641 Switch Count 0&lt;/P&gt;&lt;P&gt;Page Faults 0&lt;/P&gt;&lt;P&gt;Page Reclaims 13&lt;/P&gt;&lt;P&gt;Page Swaps 0&lt;/P&gt;&lt;P&gt;Voluntary Context Switches 0&lt;/P&gt;&lt;P&gt;Involuntary Context Switches 0&lt;/P&gt;&lt;P&gt;Block Input Operations 0&lt;/P&gt;&lt;P&gt;Block Output Operations 8&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Sep 2020 17:44:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-do-trasition-matrix-of-data/m-p/685049#M207711</guid>
      <dc:creator>y658li</dc:creator>
      <dc:date>2020-09-18T17:44:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to do trasition matrix of data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-do-trasition-matrix-of-data/m-p/685122#M207745</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/347699"&gt;@y658li&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;ERROR 133-185: A loop variable cannot be an array name or a character variable; It must be a scalar numeric.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hi this is my code:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="1" color="#000080"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt; new_table;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="1" color="#0000ff"&gt;if&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT face="Courier New" size="1" color="#008080"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT face="Courier New" size="1" color="#0000ff"&gt;then&lt;/FONT&gt; &lt;FONT face="Courier New" size="1" color="#0000ff"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt; CORP_CCAR_RESUBMIT(keep=Segment);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="1"&gt;scenario_date=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="1" color="#008080"&gt;.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="1"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="1" color="#0000ff"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt; CORP_CCAR_RESUBMIT;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="1"&gt;_n_=input(cats(actual_year,actual_quarter),&lt;/FONT&gt;&lt;FONT face="Courier New" size="1" color="#008080"&gt;yyq6.&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt;);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="1" color="#0000ff"&gt;array&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt; time Q1-Q20;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="1" color="#0000ff"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt; i=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="1" color="#008080"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT face="Courier New" size="1" color="#0000ff"&gt;to&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt; dim(time);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="1"&gt;scenario_date=intnx(&lt;/FONT&gt;&lt;FONT face="Courier New" size="1" color="#800080"&gt;'qtr'&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt;,_n_,i);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;number=time(i);&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="1" color="#0000ff"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="1" color="#0000ff"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="1" color="#0000ff"&gt;drop&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt; Q1-Q20 actual_year actual_quarter;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="1" color="#0000ff"&gt;format&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt; scenario_date &lt;/FONT&gt;&lt;FONT face="Courier New" size="1" color="#008080"&gt;yyq6.&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="1" color="#000080"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="1"&gt;and this is my log:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;127 do i=1 to dim(time);&lt;/P&gt;
&lt;P&gt;_&lt;/P&gt;
&lt;P&gt;133&lt;/P&gt;
&lt;P&gt;NOTE: The array time has the same name as a SAS-supplied or user-defined function. Parentheses following this name are treated as array references and not function references.&lt;/P&gt;
&lt;P&gt;ERROR 133-185: A loop variable cannot be an array name or a character variable; It must be a scalar numeric.&lt;/P&gt;
&lt;P&gt;NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).&lt;/P&gt;
&lt;P&gt;127:7&lt;/P&gt;
&lt;P&gt;NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).&lt;/P&gt;
&lt;P&gt;128:33 129:15&lt;/P&gt;
&lt;P&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;/P&gt;
&lt;P&gt;WARNING: The data set WORK.NEW_TABLE may be incomplete. When this step was stopped there were 0 observations and 26 variables.&lt;/P&gt;
&lt;P&gt;WARNING: Data set WORK.NEW_TABLE was not replaced because this step was stopped.&lt;/P&gt;
&lt;P&gt;NOTE: DATA statement used (Total process time):&lt;/P&gt;
&lt;P&gt;real time 0.00 seconds&lt;/P&gt;
&lt;P&gt;user cpu time 0.00 seconds&lt;/P&gt;
&lt;P&gt;system cpu time 0.00 seconds&lt;/P&gt;
&lt;P&gt;memory 435.40k&lt;/P&gt;
&lt;P&gt;OS Memory 28844.00k&lt;/P&gt;
&lt;P&gt;Timestamp 2020-09-18 01:43:05 PM&lt;/P&gt;
&lt;P&gt;Step Count 641 Switch Count 0&lt;/P&gt;
&lt;P&gt;Page Faults 0&lt;/P&gt;
&lt;P&gt;Page Reclaims 13&lt;/P&gt;
&lt;P&gt;Page Swaps 0&lt;/P&gt;
&lt;P&gt;Voluntary Context Switches 0&lt;/P&gt;
&lt;P&gt;Involuntary Context Switches 0&lt;/P&gt;
&lt;P&gt;Block Input Operations 0&lt;/P&gt;
&lt;P&gt;Block Output Operations 8&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Since your LOG does not start with "data new_table" then either your LOG entry is incomplete or you did not submit these lines:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="1" color="#000080"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt; new_table;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="1" color="#0000ff"&gt;if&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT face="Courier New" size="1" color="#008080"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT face="Courier New" size="1" color="#0000ff"&gt;then&lt;/FONT&gt; &lt;FONT face="Courier New" size="1" color="#0000ff"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt; CORP_CCAR_RESUBMIT(keep=Segment);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="1"&gt;scenario_date=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="1" color="#008080"&gt;.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="1"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="1" color="#0000ff"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt; CORP_CCAR_RESUBMIT;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="1"&gt;_n_=input(cats(actual_year,actual_quarter),&lt;/FONT&gt;&lt;FONT face="Courier New" size="1" color="#008080"&gt;yyq6.&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt;);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="1" color="#0000ff"&gt;array&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt; time Q1-Q20;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="4"&gt;Since you did not post the log into a code box as suggested then these lines:&lt;/FONT&gt;&lt;/P&gt;
&lt;PRE&gt;127 do i=1 to dim(time);

_

133

NOTE: The array time has the same name as a SAS-supplied or user-defined function. Parentheses following this name are treated as array references and not function references.

ERROR 133-185: A loop variable cannot be an array name or a character variable; It must be a scalar numeric.

NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).

127:7&lt;/PRE&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="4"&gt;Cannot be used to diagnose as intended. One critical piece of information here is the note about Numeric values converted to character at position 7 on line 127. That is what the 127:7 means.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="4"&gt;You show&lt;/FONT&gt;&lt;/P&gt;
&lt;PRE&gt;127 do i=1 to dim(time);&lt;/PRE&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="4"&gt;I have a very strong suspicion that you have a variable named I in your data set that is character. So the number 1 is being converted to '1' for the loop. Which means the "to" range is not allowed. When character values are used as loop controls they have to be listed and comma separated. However since the way you posted the incomplete log it is not possible to actual determine that 1 is actually in column 7 or not.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="4"&gt;You have notes&lt;/FONT&gt;&lt;/P&gt;
&lt;PRE&gt;NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).

128:33 129:15&lt;/PRE&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="4"&gt;Which indicates there are probably problems with lines 128 and 129. But those lines are not included. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="4"&gt;By the entire data step, &lt;STRONG&gt;in the log,&lt;/STRONG&gt; start copying at "data " and copy &lt;STRONG&gt;everything&lt;/STRONG&gt; through the last note or warning.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="4"&gt;And paste in the forum into a code box opened using the &amp;lt;/&amp;gt; icon. You can see from this post what the results look like.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="4"&gt;Here is part of log pasted as I request:&lt;/FONT&gt;&lt;/P&gt;
&lt;PRE&gt;1    data junk;
2       set sashelp.class;
3       array j _numeric_;
4       do i = '1' to dim(j);
5          x=j[i]*3;
6          put x=;
7       end;
8    run;

NOTE: Character values have been converted to numeric
      values at the places given by: (Line):(Column).
      4:11

&lt;/PRE&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="4"&gt;Here is the same thing pasted in the main message window:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;1 data junk;&lt;BR /&gt;2 set sashelp.class;&lt;BR /&gt;3 array j _numeric_;&lt;BR /&gt;4 do i = '1' to dim(j);&lt;BR /&gt;5 x=j[i]*3;&lt;BR /&gt;6 put x=;&lt;BR /&gt;7 end;&lt;BR /&gt;8 run;&lt;/P&gt;
&lt;P&gt;NOTE: Character values have been converted to numeric&lt;BR /&gt;values at the places given by: (Line):(Column).&lt;BR /&gt;4:11&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the code box I can count characters and tell that line 4:11 means the (obvious) character conversion. Without the code box you can't tell.&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>Fri, 18 Sep 2020 23:01:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-do-trasition-matrix-of-data/m-p/685122#M207745</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-09-18T23:01:38Z</dc:date>
    </item>
  </channel>
</rss>

