<?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 SAS example in documentation how to use when character? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-example-in-documentation-how-to-use-when-character/m-p/273604#M54536</link>
    <description>&lt;P&gt;I am trying to implement &lt;A title="example 2" href="http://support.sas.com/documentation/cdl/en/lestmtsref/68024/HTML/default/viewer.htm#p08do6szetrxe2n136ush727sbuo.htm" target="_self"&gt;http://support.sas.com/documentation/cdl/en/lestmtsref/68024/HTML/default/viewer.htm#p08do6szetrxe2n136ush727sbuo.htm&lt;/A&gt;&amp;nbsp;example 2&amp;nbsp;with characters as so, how can this be done?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data old;
  input start end $;
datalines;
1 a
1 b
1 c
1 d
1 e
1 f
1 g
2 a
2 b
3 a
3 b
3 c
3 d
3 e
;

data new(drop=i count);
  set old;
  by start;

  /* Create and assign values to three new variables.  Use ENDLAG1-      */
  /* ENDLAG3 to store lagged values of END, from the most recent to the  */
  /* third preceding value.                                              */   
  array x(*) endlag1-endlag3;
  endlag1=lag1(end);
  endlag2=lag2(end);
  endlag3=lag3(end);

  /* Reset COUNT at the start of each new BY-Group */
  if first.start then count=1;

  /* On each iteration, set to missing array elements   */
  /* that have not yet received a lagged value for the  */
  /* current BY-Group.  Increase count by 1.            */   
  do i=count to dim(x);
    x(i)=.;
  end;
  count + 1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 27 May 2016 15:00:50 GMT</pubDate>
    <dc:creator>dwsmith</dc:creator>
    <dc:date>2016-05-27T15:00:50Z</dc:date>
    <item>
      <title>SAS example in documentation how to use when character?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-example-in-documentation-how-to-use-when-character/m-p/273604#M54536</link>
      <description>&lt;P&gt;I am trying to implement &lt;A title="example 2" href="http://support.sas.com/documentation/cdl/en/lestmtsref/68024/HTML/default/viewer.htm#p08do6szetrxe2n136ush727sbuo.htm" target="_self"&gt;http://support.sas.com/documentation/cdl/en/lestmtsref/68024/HTML/default/viewer.htm#p08do6szetrxe2n136ush727sbuo.htm&lt;/A&gt;&amp;nbsp;example 2&amp;nbsp;with characters as so, how can this be done?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data old;
  input start end $;
datalines;
1 a
1 b
1 c
1 d
1 e
1 f
1 g
2 a
2 b
3 a
3 b
3 c
3 d
3 e
;

data new(drop=i count);
  set old;
  by start;

  /* Create and assign values to three new variables.  Use ENDLAG1-      */
  /* ENDLAG3 to store lagged values of END, from the most recent to the  */
  /* third preceding value.                                              */   
  array x(*) endlag1-endlag3;
  endlag1=lag1(end);
  endlag2=lag2(end);
  endlag3=lag3(end);

  /* Reset COUNT at the start of each new BY-Group */
  if first.start then count=1;

  /* On each iteration, set to missing array elements   */
  /* that have not yet received a lagged value for the  */
  /* current BY-Group.  Increase count by 1.            */   
  do i=count to dim(x);
    x(i)=.;
  end;
  count + 1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 May 2016 15:00:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-example-in-documentation-how-to-use-when-character/m-p/273604#M54536</guid>
      <dc:creator>dwsmith</dc:creator>
      <dc:date>2016-05-27T15:00:50Z</dc:date>
    </item>
    <item>
      <title>Re: SAS example in documentation how to use when character?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-example-in-documentation-how-to-use-when-character/m-p/273627#M54542</link>
      <description>&lt;P&gt;If I understand that you are looking to do the same processing with a character array&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data new(drop=i count);
  set old;
  by start;

/* since your first reference to the variables Endlag1 to EndLag3
  is in the array statement you need to indicate that they are
  character and HOW long they are, $ for character 1 for length
  if you used a LENGTH Endlag1-Endlag3 $ 1 prior to the array
  then the example definition would have worked*/
  array x(3) $1 endlag1-endlag3;
  endlag1=lag1(end);
  endlag2=lag2(end);
  endlag3=lag3(end);

  if first.start then count=1;

  /* On each iteration, set to missing array elements   */
  /* that have not yet received a lagged value for the  */
  /* current BY-Group.  Increase count by 1.            */   
  do i=count to dim(x);
    call missing(x(i)); /*=. doesn't work for character to set missing. 
                             Call missing works with both numeric and character*/
  end;
  count + 1;

  run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 May 2016 15:51:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-example-in-documentation-how-to-use-when-character/m-p/273627#M54542</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-05-27T15:51:21Z</dc:date>
    </item>
  </channel>
</rss>

