<?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: flagging variables, the first record, and all the records in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/flagging-variables-the-first-record-and-all-the-records/m-p/106996#M29805</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not sure if I understood what you're actually asking for. I hope below code will give you the idea how to achieve what you're after:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by subjid visit;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if subjid in (1,2) then aeflag =1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if first.subjid then injlesflag =1;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 22 Dec 2012 03:24:13 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2012-12-22T03:24:13Z</dc:date>
    <item>
      <title>flagging variables, the first record, and all the records</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/flagging-variables-the-first-record-and-all-the-records/m-p/106995#M29804</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Everyone, I've got the next dataset have:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;length visit $4;&lt;/P&gt;&lt;P&gt;length subjid aeflag injflag 8;&lt;/P&gt;&lt;P&gt;input&amp;nbsp;&amp;nbsp; subjid visit&amp;nbsp;&amp;nbsp; aeflag injflag;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;1&amp;nbsp; day1&amp;nbsp; . 1 &lt;/P&gt;&lt;P&gt;1&amp;nbsp; day2&amp;nbsp; . 1&lt;/P&gt;&lt;P&gt;1&amp;nbsp; day3&amp;nbsp; 1 1&lt;/P&gt;&lt;P&gt;1&amp;nbsp; day4&amp;nbsp; 1 1&lt;/P&gt;&lt;P&gt;1&amp;nbsp; day5&amp;nbsp; 1 .&lt;/P&gt;&lt;P&gt;2&amp;nbsp; day1&amp;nbsp; . . &lt;/P&gt;&lt;P&gt;2&amp;nbsp; day2&amp;nbsp; . .&lt;/P&gt;&lt;P&gt;2&amp;nbsp; day3&amp;nbsp; . .&lt;/P&gt;&lt;P&gt;2&amp;nbsp; day4&amp;nbsp; . 1&lt;/P&gt;&lt;P&gt;2&amp;nbsp; day5&amp;nbsp; 1 1&lt;/P&gt;&lt;P&gt;3&amp;nbsp; day1&amp;nbsp; . .&lt;/P&gt;&lt;P&gt;3&amp;nbsp; day2&amp;nbsp; . 1&lt;/P&gt;&lt;P&gt;3&amp;nbsp; day3&amp;nbsp; . 1&lt;/P&gt;&lt;P&gt;3&amp;nbsp; day4&amp;nbsp; . 1 &lt;/P&gt;&lt;P&gt;3&amp;nbsp; day5&amp;nbsp; . . &lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and I would like a dataset want, flaging the variable aeflag for all the records of subjects are qualify, it means subjid 1 and 2, and I would like flag the variable injlesflag only the first record (day1) of subjects are qualify, it means 1, 2 and 3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;V. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 22 Dec 2012 02:29:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/flagging-variables-the-first-record-and-all-the-records/m-p/106995#M29804</guid>
      <dc:creator>michtka</dc:creator>
      <dc:date>2012-12-22T02:29:56Z</dc:date>
    </item>
    <item>
      <title>Re: flagging variables, the first record, and all the records</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/flagging-variables-the-first-record-and-all-the-records/m-p/106996#M29805</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not sure if I understood what you're actually asking for. I hope below code will give you the idea how to achieve what you're after:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by subjid visit;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if subjid in (1,2) then aeflag =1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if first.subjid then injlesflag =1;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 22 Dec 2012 03:24:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/flagging-variables-the-first-record-and-all-the-records/m-p/106996#M29805</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2012-12-22T03:24:13Z</dc:date>
    </item>
    <item>
      <title>Re: flagging variables, the first record, and all the records</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/flagging-variables-the-first-record-and-all-the-records/m-p/106997#M29806</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Patrick, is not exactly it..I try to&amp;nbsp; explain it better:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rule to populate AEFLAG (many records by subject if subject is qualify):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Subject 1, show aeflag in days 3, 4 and 5, then because this subject have adverse events (subject qualify)...want to populate the rest of the days (1 and 2) also.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Subject 2, show adverse events day 5, therefore, want to populate the rest of the days too...Day 1, 2, 3 and 4.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Subject 3, dont show any adverse events, therefore is fine, it not need to be populated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rule to populate INJFLAG (1 record by subject if subject is qualify):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Subject 1, show injflag days 1 2 3 and 4, then, because this subject have injections (subject qualify)...want to populate only one record, his&lt;/P&gt;&lt;P&gt;first day (day 1).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Subject2, show inflag&amp;nbsp; days 4 and 5, again I want to populate his first day (day 1).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Subject 3, show inflag 2,3, 4, then i want to populate his first day (day 1) only.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope it helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 22 Dec 2012 03:37:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/flagging-variables-the-first-record-and-all-the-records/m-p/106997#M29806</guid>
      <dc:creator>michtka</dc:creator>
      <dc:date>2012-12-22T03:37:16Z</dc:date>
    </item>
    <item>
      <title>Re: flagging variables, the first record, and all the records</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/flagging-variables-the-first-record-and-all-the-records/m-p/106998#M29807</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your rule on 'aeflag' is clear, while on 'injflag' is still vague, as you did not say what to do with rest of the record except the first one in the group. You want to&amp;nbsp; leave them as is or you want to make them missing? The following example is to leave them unchanged, while can be easily tweaked to make them missing. Your question is usually addressed by using 2XDOW, which requires 2 passes. The following code uses Hash(), so only 1 pass is needed, hopefully is more efficient if you have a huge data set.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;length visit $4;&lt;/P&gt;&lt;P&gt;/*length subjid aeflag injflag 8;*/&lt;/P&gt;&lt;P&gt;input&amp;nbsp;&amp;nbsp; subjid visit&amp;nbsp;&amp;nbsp; aeflag injflag;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;1&amp;nbsp; day1&amp;nbsp; . 1&lt;/P&gt;&lt;P&gt;1&amp;nbsp; day2&amp;nbsp; . 1&lt;/P&gt;&lt;P&gt;1&amp;nbsp; day3&amp;nbsp; 1 1&lt;/P&gt;&lt;P&gt;1&amp;nbsp; day4&amp;nbsp; 1 1&lt;/P&gt;&lt;P&gt;1&amp;nbsp; day5&amp;nbsp; 1 .&lt;/P&gt;&lt;P&gt;2&amp;nbsp; day1&amp;nbsp; . .&lt;/P&gt;&lt;P&gt;2&amp;nbsp; day2&amp;nbsp; . .&lt;/P&gt;&lt;P&gt;2&amp;nbsp; day3&amp;nbsp; . .&lt;/P&gt;&lt;P&gt;2&amp;nbsp; day4&amp;nbsp; . 1&lt;/P&gt;&lt;P&gt;2&amp;nbsp; day5&amp;nbsp; 1 1&lt;/P&gt;&lt;P&gt;3&amp;nbsp; day1&amp;nbsp; . .&lt;/P&gt;&lt;P&gt;3&amp;nbsp; day2&amp;nbsp; . 1&lt;/P&gt;&lt;P&gt;3&amp;nbsp; day3&amp;nbsp; . 1&lt;/P&gt;&lt;P&gt;3&amp;nbsp; day4&amp;nbsp; . 1&lt;/P&gt;&lt;P&gt;3&amp;nbsp; day5&amp;nbsp; . .&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; declare hash h(multidata:'y');&lt;/P&gt;&lt;P&gt;&amp;nbsp; h.definekey('subjid','visit');&lt;/P&gt;&lt;P&gt;&amp;nbsp; h.definedata(&amp;nbsp;&amp;nbsp;&amp;nbsp; 'subjid', 'visit','aeflag','injflag');&lt;/P&gt;&lt;P&gt;&amp;nbsp; h.definedone();&lt;/P&gt;&lt;P&gt;&amp;nbsp; declare hiter hi('h');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do until (last.subjid);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; by subjid;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _aef=ifn(aeflag=1,1,_aef);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _inf=ifn(injflag=1,1,_inf);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; h.add();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; _rc=hi.first();injflag=ifn(_inf=1,1,injflag);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; do _rc=0 by 0 while (_rc=0);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; aeflag=ifn(_aef=1,1,aeflag);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _rc=hi.next();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; drop _:;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 22 Dec 2012 04:34:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/flagging-variables-the-first-record-and-all-the-records/m-p/106998#M29807</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-12-22T04:34:16Z</dc:date>
    </item>
    <item>
      <title>Re: flagging variables, the first record, and all the records</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/flagging-variables-the-first-record-and-all-the-records/m-p/106999#M29808</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Hai.kuo, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; injflag: the rest of the records have to be missing, yes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please, can you re-write your code not using the hash function...is a bit complex for me,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like you to make it more simple if it is possible.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 22 Dec 2012 04:42:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/flagging-variables-the-first-record-and-all-the-records/m-p/106999#M29808</guid>
      <dc:creator>michtka</dc:creator>
      <dc:date>2012-12-22T04:42:16Z</dc:date>
    </item>
    <item>
      <title>Re: flagging variables, the first record, and all the records</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/flagging-variables-the-first-record-and-all-the-records/m-p/107000#M29809</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Hai.kuo, I thought to make this approach:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=have out=haves;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by subjid;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*selecting subjid that show at least one injection;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=have out=injection nodupkey;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by subjid;&lt;/P&gt;&lt;P&gt;&amp;nbsp; where injflag ne .;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; merge haves(in=a keep=subjid visit aeflag) injection (in=b keep=subjid);&lt;/P&gt;&lt;P&gt;&amp;nbsp; by subjid;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if b and first.subjid then injflag=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 22 Dec 2012 04:56:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/flagging-variables-the-first-record-and-all-the-records/m-p/107000#M29809</guid>
      <dc:creator>michtka</dc:creator>
      <dc:date>2012-12-22T04:56:02Z</dc:date>
    </item>
    <item>
      <title>Re: flagging variables, the first record, and all the records</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/flagging-variables-the-first-record-and-all-the-records/m-p/107001#M29810</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Classic 2XDOW:&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do until (last.subjid);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; by subjid;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _aef=ifn(aeflag=1,1,_aef);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _inf=ifn(injflag=1,1,_inf);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; do until (last.subjid);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; by subjid;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; aeflag=ifn(_aef=1,1,aeflag);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; injflag=ifn(first.subjid,_inf,.);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; drop _:;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or Proc SQL if you like:&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; select subjid, visit, case when sum(_aef)&amp;gt;=1 then 1 else _aef end as aeflag, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case when sum(_inf)&amp;gt;=1 and monotonic()=min(monotonic()) then 1 else . end as injflag&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from have (rename=(aeflag=_aef injflag=_inf)) group by subjid order by subjid,visit;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 22 Dec 2012 04:56:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/flagging-variables-the-first-record-and-all-the-records/m-p/107001#M29810</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-12-22T04:56:35Z</dc:date>
    </item>
    <item>
      <title>Re: flagging variables, the first record, and all the records</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/flagging-variables-the-first-record-and-all-the-records/m-p/107002#M29811</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The PROC SQL is great.&lt;/P&gt;&lt;P&gt;Many thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 22 Dec 2012 05:00:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/flagging-variables-the-first-record-and-all-the-records/m-p/107002#M29811</guid>
      <dc:creator>michtka</dc:creator>
      <dc:date>2012-12-22T05:00:33Z</dc:date>
    </item>
    <item>
      <title>Re: flagging variables, the first record, and all the records</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/flagging-variables-the-first-record-and-all-the-records/m-p/107003#M29812</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My final contribution using my approach (I know there are many steps but still work);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*sorting by subjid;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=have out=haves;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by subjid;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*subjects with at least an injection;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=have out=injection nodupkey;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by subjid;&lt;/P&gt;&lt;P&gt;&amp;nbsp; where injflag ne .;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data new1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; merge haves(in=a keep=subjid visit aeflag) injection (in=b keep=subjid);&lt;/P&gt;&lt;P&gt;&amp;nbsp; by subjid;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if b and first.subjid then injflag=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*subjects with at least an adverse event;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=have out=adverse nodupkey;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by subjid;&lt;/P&gt;&lt;P&gt;&amp;nbsp; where aeflag ne .;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data new2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; merge haves(in=a keep=subjid visit aeflag) adverse (in=b keep=subjid);&lt;/P&gt;&lt;P&gt;&amp;nbsp; by subjid;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if b then aeflag=1;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*put together to create final dataset;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; merge new1(in=a) new2(in=b keep=subjid aeflag);&lt;/P&gt;&lt;P&gt;&amp;nbsp; by subjid;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 22 Dec 2012 05:10:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/flagging-variables-the-first-record-and-all-the-records/m-p/107003#M29812</guid>
      <dc:creator>michtka</dc:creator>
      <dc:date>2012-12-22T05:10:48Z</dc:date>
    </item>
    <item>
      <title>Re: flagging variables, the first record, and all the records</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/flagging-variables-the-first-record-and-all-the-records/m-p/107004#M29813</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Good for you. Glad that you are making serious commitments and solid progress.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 22 Dec 2012 13:18:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/flagging-variables-the-first-record-and-all-the-records/m-p/107004#M29813</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-12-22T13:18:20Z</dc:date>
    </item>
  </channel>
</rss>

