<?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 get these flags under the following scenarios in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-these-flags-under-the-following-scenarios/m-p/921411#M362867</link>
    <description>&lt;P&gt;I try to use the find ti position different AVALC based on the rules, but looks like not a good idea&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;proc sort data=have out=ahve_1_4 (keep=usubjid&amp;nbsp; ADY AVALC );&lt;/DIV&gt;&lt;DIV&gt;by usubjid ;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;data have_2_4;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;set have_1_4;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; if AVALC= "Y" then do;AVALC_1 ="Y";seq=0;end;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; if AVALC= "N" then do;AVALC_1 ="N";seq=1;end;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; if AVALC= "N" and ADY = .&amp;nbsp; then do;AVALC_1 ="M";seq=2;end;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;proc sort ;&lt;/DIV&gt;&lt;DIV&gt;by usubjid ;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;data have_3_4;;&lt;/DIV&gt;&lt;DIV&gt;set have_2_4;&lt;/DIV&gt;&lt;DIV&gt;by USUBJID ;&lt;/DIV&gt;&lt;DIV&gt;retain p .;&lt;/DIV&gt;&lt;DIV&gt;if first.usubjid then p=1;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;else p+1;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;proc transpose data=have_3_4 out=have_5;&lt;/DIV&gt;&lt;DIV&gt;by usubjid;&lt;/DIV&gt;&lt;DIV&gt;var AVALC_1 ;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;data have_6;&lt;/DIV&gt;&lt;DIV&gt;set have_5;&lt;/DIV&gt;&lt;DIV&gt;/*length col $800.;*/&lt;/DIV&gt;&lt;DIV&gt;col=catx(",",col1, col2,col3, col4, col5,col6 ,col7, col8, col9, col10,col11,col12,col13,col14);&lt;/DIV&gt;&lt;DIV&gt;/*if col NOT in (&amp;amp;rvar) then delete;*/&lt;/DIV&gt;&lt;DIV&gt;keep usubjid col;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;data have_7;&lt;/DIV&gt;&lt;DIV&gt;set have_6;&lt;/DIV&gt;&lt;DIV&gt;p1 = findc(col,',','i',find(col,'Y,M','i'));&lt;/DIV&gt;&lt;DIV&gt;p2 = findc(col,',','i',find(col,',M','i'));&lt;/DIV&gt;&lt;DIV&gt;p3 = findc(col,',','i',find(col,',N','i'));&lt;/DIV&gt;&lt;DIV&gt;p4 = findc(col,',','i',find(col,'M,M','i'));&lt;/DIV&gt;&lt;DIV&gt;p5 = findc(col,',','i',find(col,'N,Y','i'));&lt;/DIV&gt;&lt;DIV&gt;p6 = findc(col,',','i',find(col,',Y','i'));&lt;/DIV&gt;&lt;DIV&gt;p7 = length(col) - length(scan(col, -1, 'N') );&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;</description>
    <pubDate>Thu, 21 Mar 2024 21:09:53 GMT</pubDate>
    <dc:creator>SerenaJJ</dc:creator>
    <dc:date>2024-03-21T21:09:53Z</dc:date>
    <item>
      <title>How to get these flags under the following scenarios</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-these-flags-under-the-following-scenarios/m-p/921386#M362854</link>
      <description>&lt;P&gt;How to get these flags under the following scenarios:&lt;/P&gt;&lt;P&gt;Flag = "Y" if meet one of the following scenarios:&lt;BR /&gt;1. There is no AVALC = 'N' after the AVALC='Y' then flag should be the last non-missing record .&lt;BR /&gt;2. Subject ended with two consecutive missing ADY , then should flag the last AVALC = 'Y' prior to missed ADY.&lt;BR /&gt;4. Subject ended with one missing ADY and ADY is the last one, then should flag the last AVALC = 'Y' prior to missed ADY.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;input usubjid $ ADY AVALC $;&lt;BR /&gt;datalines;&lt;BR /&gt;A 15 Y&lt;BR /&gt;A 36 Y&lt;BR /&gt;A 57 Y&lt;BR /&gt;A 63 Y&lt;BR /&gt;A 64 Y&lt;BR /&gt;A . N&lt;BR /&gt;B 15 Y&lt;BR /&gt;B 16 Y&lt;BR /&gt;B 17 Y&lt;BR /&gt;B . N&lt;BR /&gt;B . N&lt;BR /&gt;B . N&lt;BR /&gt;B 25 N&lt;BR /&gt;B . N&lt;BR /&gt;B 29 Y&lt;BR /&gt;B 30 Y&lt;BR /&gt;B 31 Y&lt;BR /&gt;B . N&lt;BR /&gt;c 17 Y&lt;BR /&gt;c 18 Y&lt;BR /&gt;c . N&lt;BR /&gt;c . N&lt;BR /&gt;D 11 Y&lt;BR /&gt;D . N&lt;BR /&gt;D 13 Y&lt;BR /&gt;D 14 Y&lt;BR /&gt;D 15 Y&lt;BR /&gt;E 1 N&lt;BR /&gt;E 2 N&lt;BR /&gt;E 3 N&lt;BR /&gt;E 4 Y&lt;BR /&gt;;&lt;BR /&gt;run;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Records:&amp;nbsp;A 64 Y ;&amp;nbsp;B 17 Y;c 18 Y;D 15 Y;E 4 Y are flagged. Thank you so much!&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2024 19:46:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-these-flags-under-the-following-scenarios/m-p/921386#M362854</guid>
      <dc:creator>SerenaJJ</dc:creator>
      <dc:date>2024-03-21T19:46:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to get these flags under the following scenarios</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-these-flags-under-the-following-scenarios/m-p/921400#M362859</link>
      <description>&lt;P&gt;This sounds a lot like a homework assignment.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Even if that is not the case, let us know how you think about this task, and what you have tried.&amp;nbsp; Help us to help you master the problem.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2024 20:28:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-these-flags-under-the-following-scenarios/m-p/921400#M362859</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2024-03-21T20:28:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to get these flags under the following scenarios</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-these-flags-under-the-following-scenarios/m-p/921411#M362867</link>
      <description>&lt;P&gt;I try to use the find ti position different AVALC based on the rules, but looks like not a good idea&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;proc sort data=have out=ahve_1_4 (keep=usubjid&amp;nbsp; ADY AVALC );&lt;/DIV&gt;&lt;DIV&gt;by usubjid ;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;data have_2_4;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;set have_1_4;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; if AVALC= "Y" then do;AVALC_1 ="Y";seq=0;end;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; if AVALC= "N" then do;AVALC_1 ="N";seq=1;end;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; if AVALC= "N" and ADY = .&amp;nbsp; then do;AVALC_1 ="M";seq=2;end;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;proc sort ;&lt;/DIV&gt;&lt;DIV&gt;by usubjid ;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;data have_3_4;;&lt;/DIV&gt;&lt;DIV&gt;set have_2_4;&lt;/DIV&gt;&lt;DIV&gt;by USUBJID ;&lt;/DIV&gt;&lt;DIV&gt;retain p .;&lt;/DIV&gt;&lt;DIV&gt;if first.usubjid then p=1;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;else p+1;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;proc transpose data=have_3_4 out=have_5;&lt;/DIV&gt;&lt;DIV&gt;by usubjid;&lt;/DIV&gt;&lt;DIV&gt;var AVALC_1 ;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;data have_6;&lt;/DIV&gt;&lt;DIV&gt;set have_5;&lt;/DIV&gt;&lt;DIV&gt;/*length col $800.;*/&lt;/DIV&gt;&lt;DIV&gt;col=catx(",",col1, col2,col3, col4, col5,col6 ,col7, col8, col9, col10,col11,col12,col13,col14);&lt;/DIV&gt;&lt;DIV&gt;/*if col NOT in (&amp;amp;rvar) then delete;*/&lt;/DIV&gt;&lt;DIV&gt;keep usubjid col;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;data have_7;&lt;/DIV&gt;&lt;DIV&gt;set have_6;&lt;/DIV&gt;&lt;DIV&gt;p1 = findc(col,',','i',find(col,'Y,M','i'));&lt;/DIV&gt;&lt;DIV&gt;p2 = findc(col,',','i',find(col,',M','i'));&lt;/DIV&gt;&lt;DIV&gt;p3 = findc(col,',','i',find(col,',N','i'));&lt;/DIV&gt;&lt;DIV&gt;p4 = findc(col,',','i',find(col,'M,M','i'));&lt;/DIV&gt;&lt;DIV&gt;p5 = findc(col,',','i',find(col,'N,Y','i'));&lt;/DIV&gt;&lt;DIV&gt;p6 = findc(col,',','i',find(col,',Y','i'));&lt;/DIV&gt;&lt;DIV&gt;p7 = length(col) - length(scan(col, -1, 'N') );&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;</description>
      <pubDate>Thu, 21 Mar 2024 21:09:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-these-flags-under-the-following-scenarios/m-p/921411#M362867</guid>
      <dc:creator>SerenaJJ</dc:creator>
      <dc:date>2024-03-21T21:09:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to get these flags under the following scenarios</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-these-flags-under-the-following-scenarios/m-p/921412#M362868</link>
      <description>Thank you for your reply. I try to use the find to position different AVALC based on the rule, but looks like not a good idea&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;proc sort data=have out=ahve_1_4 (keep=usubjid ADY AVALC );&lt;BR /&gt;by usubjid ;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;data have_2_4;&lt;BR /&gt;set have_1_4;&lt;BR /&gt;if AVALC= "Y" then do;AVALC_1 ="Y";seq=0;end;&lt;BR /&gt;if AVALC= "N" then do;AVALC_1 ="N";seq=1;end;&lt;BR /&gt;if AVALC= "N" and ADY = . then do;AVALC_1 ="M";seq=2;end;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc sort ;&lt;BR /&gt;by usubjid ;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;data have_3_4;;&lt;BR /&gt;set have_2_4;&lt;BR /&gt;by USUBJID ;&lt;BR /&gt;retain p .;&lt;BR /&gt;if first.usubjid then p=1;&lt;BR /&gt;else p+1;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc transpose data=have_3_4 out=have_5;&lt;BR /&gt;by usubjid;&lt;BR /&gt;var AVALC_1 ;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;data have_6;&lt;BR /&gt;set have_5;&lt;BR /&gt;/*length col $800.;*/&lt;BR /&gt;col=catx(",",col1, col2,col3, col4, col5,col6 ,col7, col8, col9, col10,col11,col12,col13,col14);&lt;BR /&gt;/*if col NOT in (&amp;amp;rvar) then delete;*/&lt;BR /&gt;keep usubjid col;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;data have_7;&lt;BR /&gt;set have_6;&lt;BR /&gt;p1 = findc(col,',','i',find(col,'Y,M','i'));&lt;BR /&gt;p2 = findc(col,',','i',find(col,',M','i'));&lt;BR /&gt;p3 = findc(col,',','i',find(col,',N','i'));&lt;BR /&gt;p4 = findc(col,',','i',find(col,'M,M','i'));&lt;BR /&gt;p5 = findc(col,',','i',find(col,'N,Y','i'));&lt;BR /&gt;p6 = findc(col,',','i',find(col,',Y','i'));&lt;BR /&gt;p7 = length(col) - length(scan(col, -1, 'N') );&lt;BR /&gt;&lt;BR /&gt;run;</description>
      <pubDate>Thu, 21 Mar 2024 21:11:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-these-flags-under-the-following-scenarios/m-p/921412#M362868</guid>
      <dc:creator>SerenaJJ</dc:creator>
      <dc:date>2024-03-21T21:11:09Z</dc:date>
    </item>
  </channel>
</rss>

