<?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 Help with ARRAY, Loops. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Help-with-ARRAY-Loops/m-p/197109#M36969</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: times new roman,times;"&gt; I am tracking student cohorts over time to identify when students transfer out of the college and which terms they are co-enrolled at my college (HOME) and another institution (TRFINST) at the same time. This is a many to many match between the student’s HOME semesters and the TRFINST semesters.&amp;nbsp; I can identify the multiple semesters that&lt;BR /&gt;students were “co-enrolled” (enrolled at Home and a TRFINST in the same semester) and the semesters that students transferred to a TRFINST.&amp;nbsp; My problem is that project requirements are that after a student is identified as a student is identified as a Transfer Student,&amp;nbsp; that transfer semester is to be reported an no further tracked terms are to be reported.&amp;nbsp;&amp;nbsp; I am&lt;BR /&gt;trying to revise a program that I use to track retention using the same type data but am bogged down on how to eliminate future values for students identified as Transfer students.&amp;nbsp; (i.e., student transfers and then comes back to HOME for a semester and later transfers to another college - no data after the first transfer is to be reported). I figure I can transpose the data results I have, unduplicate it,&amp;nbsp; and then remerge the data again.&amp;nbsp; But would like to do it without all that manipulation. So any ideas will be appreciated.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: times new roman,times;"&gt;I have attached a program Headach.SAS and a sample SAS file (&lt;SPAN style="background: white; color: black;"&gt;TEST_TRF_PROJ2)&lt;/SPAN&gt;&lt;SPAN style="color: black;"&gt;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ENRTERM(I) - "1" indicates the student was enrolled at HOME; TRFSEM(I)- "1"&amp;nbsp; indicates the student was enrolled at TRFINST; The variable index numbers are based on the student's cohort term and indicate the numbers of semesters since the cohort term.&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;Student 23 has become my “test” student and should have a “1” value for &lt;SPAN style="background: white;"&gt;COENRSEM&lt;/SPAN&gt; 3-7 and 0 for &lt;SPAN style="background: white;"&gt;COENRSEM&lt;/SPAN&gt; 9-15; and a “1” value for &lt;STRONG&gt;XSEMTRF&lt;/STRONG&gt;9 and “0” for the &lt;STRONG&gt;XSEMTRF&lt;/STRONG&gt;1-9 and 10-15.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: %value;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 09 Mar 2015 04:43:09 GMT</pubDate>
    <dc:creator>madhatter</dc:creator>
    <dc:date>2015-03-09T04:43:09Z</dc:date>
    <item>
      <title>Help with ARRAY, Loops.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-ARRAY-Loops/m-p/197109#M36969</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: times new roman,times;"&gt; I am tracking student cohorts over time to identify when students transfer out of the college and which terms they are co-enrolled at my college (HOME) and another institution (TRFINST) at the same time. This is a many to many match between the student’s HOME semesters and the TRFINST semesters.&amp;nbsp; I can identify the multiple semesters that&lt;BR /&gt;students were “co-enrolled” (enrolled at Home and a TRFINST in the same semester) and the semesters that students transferred to a TRFINST.&amp;nbsp; My problem is that project requirements are that after a student is identified as a student is identified as a Transfer Student,&amp;nbsp; that transfer semester is to be reported an no further tracked terms are to be reported.&amp;nbsp;&amp;nbsp; I am&lt;BR /&gt;trying to revise a program that I use to track retention using the same type data but am bogged down on how to eliminate future values for students identified as Transfer students.&amp;nbsp; (i.e., student transfers and then comes back to HOME for a semester and later transfers to another college - no data after the first transfer is to be reported). I figure I can transpose the data results I have, unduplicate it,&amp;nbsp; and then remerge the data again.&amp;nbsp; But would like to do it without all that manipulation. So any ideas will be appreciated.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: times new roman,times;"&gt;I have attached a program Headach.SAS and a sample SAS file (&lt;SPAN style="background: white; color: black;"&gt;TEST_TRF_PROJ2)&lt;/SPAN&gt;&lt;SPAN style="color: black;"&gt;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ENRTERM(I) - "1" indicates the student was enrolled at HOME; TRFSEM(I)- "1"&amp;nbsp; indicates the student was enrolled at TRFINST; The variable index numbers are based on the student's cohort term and indicate the numbers of semesters since the cohort term.&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;Student 23 has become my “test” student and should have a “1” value for &lt;SPAN style="background: white;"&gt;COENRSEM&lt;/SPAN&gt; 3-7 and 0 for &lt;SPAN style="background: white;"&gt;COENRSEM&lt;/SPAN&gt; 9-15; and a “1” value for &lt;STRONG&gt;XSEMTRF&lt;/STRONG&gt;9 and “0” for the &lt;STRONG&gt;XSEMTRF&lt;/STRONG&gt;1-9 and 10-15.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: %value;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Mar 2015 04:43:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-ARRAY-Loops/m-p/197109#M36969</guid>
      <dc:creator>madhatter</dc:creator>
      <dc:date>2015-03-09T04:43:09Z</dc:date>
    </item>
    <item>
      <title>Re: Help with ARRAY, Loops.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-ARRAY-Loops/m-p/342506#M78538</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/7949"&gt;@madhatter&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;unfortunately I am not sure, what your exact requirements are.&lt;/P&gt;
&lt;P&gt;The fields coho, cohoterm and enr were not explained so I did not use them any further.&lt;/P&gt;
&lt;P&gt;I understand that you have 15 semesters of data?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here would be my code that does give you per ssn (ssn is the student number?) and per semester:&lt;/P&gt;
&lt;P&gt;If a student is enrolled at your home college and enrolled at a foreign college.&lt;/P&gt;
&lt;P&gt;Plus the first occasion, when a student is enrolled only at a foreign college and no more lines for that student afterwards.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Given the numbers in your fields indicate the semesters and are in correct order (i.e. enrterm1 means enrolment in semester 1).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
/* transpose data */
DATA have_1 (keep = ssn coho cohoterm semester enrol_home enrol_abroad);
	SET have;
ARRAY TRFSEM (15) TRFSEM1-TRFSEM15;/*TERMS  STU ENROLLED OTHER COLLEGES*/
ARRAY ENRTERM(15) ENRTERM1-ENRTERM15;/*TERMS STU ENROLLED HOME COLLEGE*/

DO I=1 TO 15;
  if trfsem(I) = 1 then enrol_abroad = 1; else enrol_abroad = 0;
  if enrterm(I) = 1 then enrol_home = 1; else enrol_home = 0;
  semester = I;
  output;
END;

RUN;

/* sort data for by-processing in next step */
proc sort data = have_1;
by ssn semester;
run;

data want;
set have_1;
by ssn semester;
retain outputline;

  /* set "outputline" to make sure there is no more output after 
     a transfer student has been found and is in output once */
  if first.ssn then outputline = 1;

  /* criteria to find */
  if enrol_home and enrol_abroad and outputline then output; /* student enrolled home and abroad */
  else if not enrol_home and enrol_abroad and outputline /* transfer student */
         then do;
                output;
                outputline = 0;
              end;

  drop outputline; /* no need to output that */
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Not sure, if this meets your requirements. Let me know if you had something else in mind.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you need more information, you can always edit the logic in the last data step. For instance, create new columns like 'transfer_student', 'fist_semester_abroad', etc.&lt;/P&gt;
&lt;P&gt;By using the retain statement, you can determine further information per student, as desired.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;Michael&lt;/P&gt;</description>
      <pubDate>Mon, 20 Mar 2017 09:56:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-ARRAY-Loops/m-p/342506#M78538</guid>
      <dc:creator>mfab</dc:creator>
      <dc:date>2017-03-20T09:56:35Z</dc:date>
    </item>
  </channel>
</rss>

