<?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: Variable to identify individuals whose type of diabetes changes from one hospital visit to  anot in Advanced Programming</title>
    <link>https://communities.sas.com/t5/Advanced-Programming/Variable-to-identify-individuals-whose-type-of-diabetes-changes/m-p/803895#M176</link>
    <description>My data contains more than 20,000 observations. What I present here is only a Sample.</description>
    <pubDate>Thu, 24 Mar 2022 20:09:20 GMT</pubDate>
    <dc:creator>Wylyann</dc:creator>
    <dc:date>2022-03-24T20:09:20Z</dc:date>
    <item>
      <title>Variable to identify individuals whose type of diabetes changes from one hospital visit to  another</title>
      <link>https://communities.sas.com/t5/Advanced-Programming/Variable-to-identify-individuals-whose-type-of-diabetes-changes/m-p/803878#M171</link>
      <description>&lt;P&gt;Hello, can anyone help me?&lt;BR /&gt;I have some medico-administrative data and I want to create a binomial variable that will code an individual as 1, if the type of diabetes diagnosed is constant from one hospital visit to another; and code 0, if the type of diabetes diagnosed varies according to the hospital visit.&lt;BR /&gt;This is what my medico-administrative data looks like:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Observation (numeric)&lt;/TD&gt;&lt;TD&gt;Id (numeric)&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;Hospital visit Number (alphanumeric)&lt;/TD&gt;&lt;TD&gt;Type of diabetes diagnosed (numeric)&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;04&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;05&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;07&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;15&lt;/TD&gt;&lt;TD&gt;01&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;15&lt;/TD&gt;&lt;TD&gt;02&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;18&lt;/TD&gt;&lt;TD&gt;03&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;TD&gt;22&lt;/TD&gt;&lt;TD&gt;06&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;TD&gt;30&lt;/TD&gt;&lt;TD&gt;01&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;TD&gt;30&lt;/TD&gt;&lt;TD&gt;03&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;30&lt;/TD&gt;&lt;TD&gt;04&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Thu, 24 Mar 2022 19:19:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Advanced-Programming/Variable-to-identify-individuals-whose-type-of-diabetes-changes/m-p/803878#M171</guid>
      <dc:creator>Wylyann</dc:creator>
      <dc:date>2022-03-24T19:19:17Z</dc:date>
    </item>
    <item>
      <title>Re: Variable to identify individuals whose type of diabetes changes from one hospital visit to  anot</title>
      <link>https://communities.sas.com/t5/Advanced-Programming/Variable-to-identify-individuals-whose-type-of-diabetes-changes/m-p/803881#M172</link>
      <description>&lt;P&gt;Across all distinct hospital visits?&lt;/P&gt;</description>
      <pubDate>Thu, 24 Mar 2022 19:31:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Advanced-Programming/Variable-to-identify-individuals-whose-type-of-diabetes-changes/m-p/803881#M172</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-03-24T19:31:21Z</dc:date>
    </item>
    <item>
      <title>Re: Variable to identify individuals whose type of diabetes changes from one hospital visit to  anot</title>
      <link>https://communities.sas.com/t5/Advanced-Programming/Variable-to-identify-individuals-whose-type-of-diabetes-changes/m-p/803883#M173</link>
      <description>&lt;P&gt;Can you show what you expect the result to look like?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are the ONLY values for the diabetes variable 1 and 2?&lt;/P&gt;</description>
      <pubDate>Thu, 24 Mar 2022 19:33:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Advanced-Programming/Variable-to-identify-individuals-whose-type-of-diabetes-changes/m-p/803883#M173</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-03-24T19:33:47Z</dc:date>
    </item>
    <item>
      <title>Re: Variable to identify individuals whose type of diabetes changes from one hospital visit to  anot</title>
      <link>https://communities.sas.com/t5/Advanced-Programming/Variable-to-identify-individuals-whose-type-of-diabetes-changes/m-p/803886#M174</link>
      <description>&lt;P&gt;No, for each individual.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Mar 2022 19:39:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Advanced-Programming/Variable-to-identify-individuals-whose-type-of-diabetes-changes/m-p/803886#M174</guid>
      <dc:creator>Wylyann</dc:creator>
      <dc:date>2022-03-24T19:39:41Z</dc:date>
    </item>
    <item>
      <title>Re: Variable to identify individuals whose type of diabetes changes from one hospital visit to  anot</title>
      <link>https://communities.sas.com/t5/Advanced-Programming/Variable-to-identify-individuals-whose-type-of-diabetes-changes/m-p/803893#M175</link>
      <description>Yes, the only values for the diabetes variable are 1 (type 1 diabetes mellitus) and 2 (type 2 diabetes mellitus).&lt;BR /&gt;&lt;BR /&gt;This involves writing a command that automatically creates the variable "Type of diabetes evolution" (TDevolution) that assigns code 1 to individuals (Id) "3", "18" and "22"; then code 0 to Id "15" and "30".</description>
      <pubDate>Thu, 24 Mar 2022 20:03:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Advanced-Programming/Variable-to-identify-individuals-whose-type-of-diabetes-changes/m-p/803893#M175</guid>
      <dc:creator>Wylyann</dc:creator>
      <dc:date>2022-03-24T20:03:44Z</dc:date>
    </item>
    <item>
      <title>Re: Variable to identify individuals whose type of diabetes changes from one hospital visit to  anot</title>
      <link>https://communities.sas.com/t5/Advanced-Programming/Variable-to-identify-individuals-whose-type-of-diabetes-changes/m-p/803895#M176</link>
      <description>My data contains more than 20,000 observations. What I present here is only a Sample.</description>
      <pubDate>Thu, 24 Mar 2022 20:09:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Advanced-Programming/Variable-to-identify-individuals-whose-type-of-diabetes-changes/m-p/803895#M176</guid>
      <dc:creator>Wylyann</dc:creator>
      <dc:date>2022-03-24T20:09:20Z</dc:date>
    </item>
    <item>
      <title>Re: Variable to identify individuals whose type of diabetes changes from one hospital visit to  anot</title>
      <link>https://communities.sas.com/t5/Advanced-Programming/Variable-to-identify-individuals-whose-type-of-diabetes-changes/m-p/803898#M177</link>
      <description>&lt;P&gt;Read each ID twice, the first time to set a flag if there is a change in diabetes type.&amp;nbsp; The second time to output data if the flag was set:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But the original code I sent included the NOTSORTED option in the by statement - which is not supported when SET has more than one input dataset.&amp;nbsp; So&amp;nbsp; "by id diabetes_type nosorted" needs to be reset to "by id", and the subsequent code needs to be changed, as here:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want (drop=_:);
  set have (in=firstpass)  have (in=secondpass);
  by id;
  retain _keep_this_id 0;
  if first.id=1 then _keep_this_id=0;
  if first.id=0 and diabetes_type^=lag(diabetes_type) then _keep_this_id=1;
  if secondpass=1 and _keep_this_id=1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The original code (below) should not be used, and will be flagged by SAS:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;STRIKE&gt;&lt;CODE class=" language-sas"&gt;data want (drop=_:);
  set have (in=firstpass)  have (in=secondpass);
  by id diabetes_type notsorted;
  retain _keep_this_id 0;
  if first.id=1 then _keep_this_id=0;
  if first.id=0 and first.diabetes_type=1 then _keep_this_id=1;
  if secondpass=1 and _keep_this_id=1;
run;
&lt;/CODE&gt;&lt;/STRIKE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRIKE&gt;The &lt;EM&gt;&lt;STRONG&gt;first.id=0 and first.diabetes=1&lt;/STRONG&gt;&lt;/EM&gt; condition tests for a change in diabetes others than at the beginning of the ID.&amp;nbsp; &amp;nbsp;Because diabetes can change up, or change down., the BY statement has the &lt;EM&gt;&lt;STRONG&gt;notsorted&lt;/STRONG&gt;&lt;/EM&gt; parameter.&lt;/STRIKE&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Mar 2025 03:27:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Advanced-Programming/Variable-to-identify-individuals-whose-type-of-diabetes-changes/m-p/803898#M177</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2025-03-21T03:27:27Z</dc:date>
    </item>
    <item>
      <title>Re: Variable to identify individuals whose type of diabetes changes from one hospital visit to  anot</title>
      <link>https://communities.sas.com/t5/Advanced-Programming/Variable-to-identify-individuals-whose-type-of-diabetes-changes/m-p/803921#M178</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/420795"&gt;@Wylyann&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Yes, the only values for the diabetes variable are 1 (type 1 diabetes mellitus) and 2 (type 2 diabetes mellitus).&lt;BR /&gt;&lt;BR /&gt;This involves writing a command that automatically creates the variable "Type of diabetes evolution" (TDevolution) that assigns code 1 to individuals (Id) "3", "18" and "22"; then code 0 to Id "15" and "30".&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Still have NOT &lt;STRONG&gt;shown&lt;/STRONG&gt; what the resulting data set is supposed to look like.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Mar 2022 22:18:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Advanced-Programming/Variable-to-identify-individuals-whose-type-of-diabetes-changes/m-p/803921#M178</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-03-24T22:18:06Z</dc:date>
    </item>
    <item>
      <title>Re: Variable to identify individuals whose type of diabetes changes from one hospital visit to  anot</title>
      <link>https://communities.sas.com/t5/Advanced-Programming/Variable-to-identify-individuals-whose-type-of-diabetes-changes/m-p/804539#M179</link>
      <description>&lt;P&gt;Maybe I didn't understand you correctly. Can you reformulate your question, please?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Mar 2022 15:43:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Advanced-Programming/Variable-to-identify-individuals-whose-type-of-diabetes-changes/m-p/804539#M179</guid>
      <dc:creator>Wylyann</dc:creator>
      <dc:date>2022-03-28T15:43:44Z</dc:date>
    </item>
  </channel>
</rss>

