<?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 Numbering rows according to certain rule in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Numbering-rows-according-to-certain-rule/m-p/842721#M333222</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I have the attached data set, in which the first 5 variables are part of the data set and the last variable, "year_of_tenure", is the&amp;nbsp;variable I&amp;nbsp; want to calculate through SAS code.&lt;/P&gt;
&lt;P&gt;The variable "year_start01" is the year the tenure starts&lt;/P&gt;
&lt;P&gt;The variable "year_end01" is the year the tenure ends&lt;/P&gt;
&lt;P&gt;The variable "year" include several years within this tenure range. &lt;STRONG&gt;This variable doesn't include all the years of the tenure&lt;/STRONG&gt;.&amp;nbsp;I would like to calculate the variable "year_of_tenure", so if for example "year_start01" is 2000, then near the year "2001" the "year_of_tenure" will be 2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance,&lt;/P&gt;
&lt;P&gt;Lior&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
/* --------------------------------------------------------------------
   Code generated by a SAS task
   
   Generated on Sunday, November 6, 2022 at 12:47:56 PM
   By task:     Import Data Wizard
   
   Source file: C:\Users\Lior\Downloads\year_of_tenure.xlsx
   Server:      Local File System
   
   Output data: WORK.year_of_tenure
   Server:      Local
   -------------------------------------------------------------------- */

/* --------------------------------------------------------------------
   This DATA step reads the data values from DATALINES within the SAS
   code. The values within the DATALINES were extracted from the Excel
   source file by the Import Data wizard.
   -------------------------------------------------------------------- */

DATA WORK.year_of_tenure;
    LENGTH
        GVKEY01          $ 6
        Full_Name        $ 22
        year_start01       8
        year_end01         8
        year               8
        year_of_tenure     8 ;
    FORMAT
        GVKEY01          $CHAR6.
        Full_Name        $CHAR22.
        year_start01     BEST12.
        year_end01       BEST12.
        year             BEST12.
        year_of_tenure   BEST12. ;
    INFORMAT
        GVKEY01          $CHAR6.
        Full_Name        $CHAR22.
        year_start01     BEST12.
        year_end01       BEST12.
        year             BEST12.
        year_of_tenure   BEST12. ;
    INFILE DATALINES4
        DLM='7F'x
        MISSOVER
        DSD ;
    INPUT
        GVKEY01          : $CHAR6.
        Full_Name        : $CHAR22.
        year_start01     : BEST32.
        year_end01       : BEST32.
        year             : BEST32.
        year_of_tenure   : BEST32. ;
DATALINES4;
001034&amp;#127;Ingrid Wiik&amp;#127;2000&amp;#127;2005&amp;#127;2001&amp;#127;2
001034&amp;#127;Ingrid Wiik&amp;#127;2000&amp;#127;2005&amp;#127;2002&amp;#127;3
001034&amp;#127;Ingrid Wiik&amp;#127;2000&amp;#127;2005&amp;#127;2003&amp;#127;4
001034&amp;#127;Ingrid Wiik&amp;#127;2000&amp;#127;2005&amp;#127;2004&amp;#127;5
001078&amp;#127;Miles D. White, M.B.A.&amp;#127;1999&amp;#127;2019&amp;#127;2002&amp;#127;4
001078&amp;#127;Miles D. White, M.B.A.&amp;#127;1999&amp;#127;2019&amp;#127;2003&amp;#127;5
001078&amp;#127;Miles D. White, M.B.A.&amp;#127;1999&amp;#127;2019&amp;#127;2004&amp;#127;6
001078&amp;#127;Miles D. White, M.B.A.&amp;#127;1999&amp;#127;2019&amp;#127;2005&amp;#127;7
001078&amp;#127;Miles D. White, M.B.A.&amp;#127;1999&amp;#127;2019&amp;#127;2006&amp;#127;8
001078&amp;#127;Miles D. White, M.B.A.&amp;#127;1999&amp;#127;2019&amp;#127;2007&amp;#127;9
001078&amp;#127;Miles D. White, M.B.A.&amp;#127;1999&amp;#127;2019&amp;#127;2008&amp;#127;10
001078&amp;#127;Miles D. White, M.B.A.&amp;#127;1999&amp;#127;2019&amp;#127;2009&amp;#127;11
001078&amp;#127;Miles D. White, M.B.A.&amp;#127;1999&amp;#127;2019&amp;#127;2010&amp;#127;12
001078&amp;#127;Miles D. White, M.B.A.&amp;#127;1999&amp;#127;2019&amp;#127;2011&amp;#127;13
001078&amp;#127;Miles D. White, M.B.A.&amp;#127;1999&amp;#127;2019&amp;#127;2012&amp;#127;14
001078&amp;#127;Miles D. White, M.B.A.&amp;#127;1999&amp;#127;2019&amp;#127;2013&amp;#127;15
001078&amp;#127;Miles D. White, M.B.A.&amp;#127;1999&amp;#127;2019&amp;#127;2014&amp;#127;16
001078&amp;#127;Miles D. White, M.B.A.&amp;#127;1999&amp;#127;2019&amp;#127;2015&amp;#127;17
001078&amp;#127;Miles D. White, M.B.A.&amp;#127;1999&amp;#127;2019&amp;#127;2016&amp;#127;18
001078&amp;#127;Miles D. White, M.B.A.&amp;#127;1999&amp;#127;2019&amp;#127;2017&amp;#127;19
001078&amp;#127;Miles D. White, M.B.A.&amp;#127;1999&amp;#127;2019&amp;#127;2018&amp;#127;20
001078&amp;#127;Miles D. White, M.B.A.&amp;#127;1999&amp;#127;2019&amp;#127;2019&amp;#127;21
001177&amp;#127;John W. Rowe&amp;#127;2001&amp;#127;2005&amp;#127;2001&amp;#127;1
001177&amp;#127;John W. Rowe&amp;#127;2001&amp;#127;2005&amp;#127;2003&amp;#127;2
001177&amp;#127;John W. Rowe&amp;#127;2001&amp;#127;2005&amp;#127;2004&amp;#127;3
001177&amp;#127;John W. Rowe&amp;#127;2001&amp;#127;2005&amp;#127;2005&amp;#127;4
;;;;



&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 06 Nov 2022 11:13:15 GMT</pubDate>
    <dc:creator>lioradam</dc:creator>
    <dc:date>2022-11-06T11:13:15Z</dc:date>
    <item>
      <title>Numbering rows according to certain rule</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Numbering-rows-according-to-certain-rule/m-p/842721#M333222</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I have the attached data set, in which the first 5 variables are part of the data set and the last variable, "year_of_tenure", is the&amp;nbsp;variable I&amp;nbsp; want to calculate through SAS code.&lt;/P&gt;
&lt;P&gt;The variable "year_start01" is the year the tenure starts&lt;/P&gt;
&lt;P&gt;The variable "year_end01" is the year the tenure ends&lt;/P&gt;
&lt;P&gt;The variable "year" include several years within this tenure range. &lt;STRONG&gt;This variable doesn't include all the years of the tenure&lt;/STRONG&gt;.&amp;nbsp;I would like to calculate the variable "year_of_tenure", so if for example "year_start01" is 2000, then near the year "2001" the "year_of_tenure" will be 2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance,&lt;/P&gt;
&lt;P&gt;Lior&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
/* --------------------------------------------------------------------
   Code generated by a SAS task
   
   Generated on Sunday, November 6, 2022 at 12:47:56 PM
   By task:     Import Data Wizard
   
   Source file: C:\Users\Lior\Downloads\year_of_tenure.xlsx
   Server:      Local File System
   
   Output data: WORK.year_of_tenure
   Server:      Local
   -------------------------------------------------------------------- */

/* --------------------------------------------------------------------
   This DATA step reads the data values from DATALINES within the SAS
   code. The values within the DATALINES were extracted from the Excel
   source file by the Import Data wizard.
   -------------------------------------------------------------------- */

DATA WORK.year_of_tenure;
    LENGTH
        GVKEY01          $ 6
        Full_Name        $ 22
        year_start01       8
        year_end01         8
        year               8
        year_of_tenure     8 ;
    FORMAT
        GVKEY01          $CHAR6.
        Full_Name        $CHAR22.
        year_start01     BEST12.
        year_end01       BEST12.
        year             BEST12.
        year_of_tenure   BEST12. ;
    INFORMAT
        GVKEY01          $CHAR6.
        Full_Name        $CHAR22.
        year_start01     BEST12.
        year_end01       BEST12.
        year             BEST12.
        year_of_tenure   BEST12. ;
    INFILE DATALINES4
        DLM='7F'x
        MISSOVER
        DSD ;
    INPUT
        GVKEY01          : $CHAR6.
        Full_Name        : $CHAR22.
        year_start01     : BEST32.
        year_end01       : BEST32.
        year             : BEST32.
        year_of_tenure   : BEST32. ;
DATALINES4;
001034&amp;#127;Ingrid Wiik&amp;#127;2000&amp;#127;2005&amp;#127;2001&amp;#127;2
001034&amp;#127;Ingrid Wiik&amp;#127;2000&amp;#127;2005&amp;#127;2002&amp;#127;3
001034&amp;#127;Ingrid Wiik&amp;#127;2000&amp;#127;2005&amp;#127;2003&amp;#127;4
001034&amp;#127;Ingrid Wiik&amp;#127;2000&amp;#127;2005&amp;#127;2004&amp;#127;5
001078&amp;#127;Miles D. White, M.B.A.&amp;#127;1999&amp;#127;2019&amp;#127;2002&amp;#127;4
001078&amp;#127;Miles D. White, M.B.A.&amp;#127;1999&amp;#127;2019&amp;#127;2003&amp;#127;5
001078&amp;#127;Miles D. White, M.B.A.&amp;#127;1999&amp;#127;2019&amp;#127;2004&amp;#127;6
001078&amp;#127;Miles D. White, M.B.A.&amp;#127;1999&amp;#127;2019&amp;#127;2005&amp;#127;7
001078&amp;#127;Miles D. White, M.B.A.&amp;#127;1999&amp;#127;2019&amp;#127;2006&amp;#127;8
001078&amp;#127;Miles D. White, M.B.A.&amp;#127;1999&amp;#127;2019&amp;#127;2007&amp;#127;9
001078&amp;#127;Miles D. White, M.B.A.&amp;#127;1999&amp;#127;2019&amp;#127;2008&amp;#127;10
001078&amp;#127;Miles D. White, M.B.A.&amp;#127;1999&amp;#127;2019&amp;#127;2009&amp;#127;11
001078&amp;#127;Miles D. White, M.B.A.&amp;#127;1999&amp;#127;2019&amp;#127;2010&amp;#127;12
001078&amp;#127;Miles D. White, M.B.A.&amp;#127;1999&amp;#127;2019&amp;#127;2011&amp;#127;13
001078&amp;#127;Miles D. White, M.B.A.&amp;#127;1999&amp;#127;2019&amp;#127;2012&amp;#127;14
001078&amp;#127;Miles D. White, M.B.A.&amp;#127;1999&amp;#127;2019&amp;#127;2013&amp;#127;15
001078&amp;#127;Miles D. White, M.B.A.&amp;#127;1999&amp;#127;2019&amp;#127;2014&amp;#127;16
001078&amp;#127;Miles D. White, M.B.A.&amp;#127;1999&amp;#127;2019&amp;#127;2015&amp;#127;17
001078&amp;#127;Miles D. White, M.B.A.&amp;#127;1999&amp;#127;2019&amp;#127;2016&amp;#127;18
001078&amp;#127;Miles D. White, M.B.A.&amp;#127;1999&amp;#127;2019&amp;#127;2017&amp;#127;19
001078&amp;#127;Miles D. White, M.B.A.&amp;#127;1999&amp;#127;2019&amp;#127;2018&amp;#127;20
001078&amp;#127;Miles D. White, M.B.A.&amp;#127;1999&amp;#127;2019&amp;#127;2019&amp;#127;21
001177&amp;#127;John W. Rowe&amp;#127;2001&amp;#127;2005&amp;#127;2001&amp;#127;1
001177&amp;#127;John W. Rowe&amp;#127;2001&amp;#127;2005&amp;#127;2003&amp;#127;2
001177&amp;#127;John W. Rowe&amp;#127;2001&amp;#127;2005&amp;#127;2004&amp;#127;3
001177&amp;#127;John W. Rowe&amp;#127;2001&amp;#127;2005&amp;#127;2005&amp;#127;4
;;;;



&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 06 Nov 2022 11:13:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Numbering-rows-according-to-certain-rule/m-p/842721#M333222</guid>
      <dc:creator>lioradam</dc:creator>
      <dc:date>2022-11-06T11:13:15Z</dc:date>
    </item>
    <item>
      <title>Re: Numbering rows according to certain rule</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Numbering-rows-according-to-certain-rule/m-p/842733#M333225</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set year_of_tenure;
by gvkey01;
retain start;
if first.gvkey01 then start = year_start01;
year_of_tenure = year - start + 1;
drop start;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 06 Nov 2022 13:03:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Numbering-rows-according-to-certain-rule/m-p/842733#M333225</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-11-06T13:03:51Z</dc:date>
    </item>
    <item>
      <title>Re: Numbering rows according to certain rule</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Numbering-rows-according-to-certain-rule/m-p/842746#M333227</link>
      <description>Great, thanks.&lt;BR /&gt;Lior</description>
      <pubDate>Sun, 06 Nov 2022 13:45:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Numbering-rows-according-to-certain-rule/m-p/842746#M333227</guid>
      <dc:creator>lioradam</dc:creator>
      <dc:date>2022-11-06T13:45:56Z</dc:date>
    </item>
  </channel>
</rss>

