<?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 MDY &amp; datdiff functions (longitudinal data set) in SAS Health and Life Sciences</title>
    <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/MDY-datdiff-functions-longitudinal-data-set/m-p/136190#M1880</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;New, and slightly reluctant, SAS user (previously STATA user)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SAS dates have me scratching my head a bit. I have a longitudinal dataset, but I am currently only interested in baseline (e.g. first questionnaire) data for which I have created a new dataset. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Variables: &lt;/P&gt;&lt;P&gt;(a) Date of Baseline Questionnaire: var1 = DDMMYYYY (SAS Informat: DDMMYYYY8)&lt;/P&gt;&lt;P&gt;(b) Known Disease Exposure?: var2: yes(1), no(0), don'tknow(88), refused(99) --&amp;gt; ONLY those that responded YES had the next question asked: &lt;/P&gt;&lt;P&gt;(c) Date of Disease Exposure: var3 =&amp;nbsp; MM (0-12, 0=unknown, 1=January etc.), var4 = YYYY &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Goal: &lt;/P&gt;&lt;P&gt;Determine "Time Since Exposure" from baseline questionnaire &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I'd like to do/think I should be doing: &lt;/P&gt;&lt;P&gt;1. Only analyse those individuals at baseline who responded "YES(1)" to var2&lt;/P&gt;&lt;P&gt;2. Assign/impute the middle of each month (e.g. 15th day) as a new variable to every individual (create: var5)&lt;/P&gt;&lt;P&gt;3. Create a new variable: 'DateExp' (var6) -- this will combine var3-5 in to a single variable represented as: DDMMYYY (equivalent to: var5-var3-var4)&lt;/P&gt;&lt;P&gt;- I believe I need to use the MDY function; but the SAS examples are not easily understood (again, being a new user!) &lt;/P&gt;&lt;P&gt;4. Calculate time since exposure (TimeSinceExp=var2-var6/365.25) with an output in Years, rounded to a single decimal (e.g. 5.4 years) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any assistance would be appreciated. I am pondering this away today and will check in tomorrow to see how close (or far off!) my own code is....so far about 20% of my more complicated coding works (which I would say isn't too bad for 2nd week of use). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best &amp;amp; many thanks in advance. &lt;/P&gt;&lt;P&gt;-Tyler &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 10 Jun 2014 16:00:05 GMT</pubDate>
    <dc:creator>toneill</dc:creator>
    <dc:date>2014-06-10T16:00:05Z</dc:date>
    <item>
      <title>MDY &amp; datdiff functions (longitudinal data set)</title>
      <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/MDY-datdiff-functions-longitudinal-data-set/m-p/136190#M1880</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;New, and slightly reluctant, SAS user (previously STATA user)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SAS dates have me scratching my head a bit. I have a longitudinal dataset, but I am currently only interested in baseline (e.g. first questionnaire) data for which I have created a new dataset. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Variables: &lt;/P&gt;&lt;P&gt;(a) Date of Baseline Questionnaire: var1 = DDMMYYYY (SAS Informat: DDMMYYYY8)&lt;/P&gt;&lt;P&gt;(b) Known Disease Exposure?: var2: yes(1), no(0), don'tknow(88), refused(99) --&amp;gt; ONLY those that responded YES had the next question asked: &lt;/P&gt;&lt;P&gt;(c) Date of Disease Exposure: var3 =&amp;nbsp; MM (0-12, 0=unknown, 1=January etc.), var4 = YYYY &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Goal: &lt;/P&gt;&lt;P&gt;Determine "Time Since Exposure" from baseline questionnaire &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I'd like to do/think I should be doing: &lt;/P&gt;&lt;P&gt;1. Only analyse those individuals at baseline who responded "YES(1)" to var2&lt;/P&gt;&lt;P&gt;2. Assign/impute the middle of each month (e.g. 15th day) as a new variable to every individual (create: var5)&lt;/P&gt;&lt;P&gt;3. Create a new variable: 'DateExp' (var6) -- this will combine var3-5 in to a single variable represented as: DDMMYYY (equivalent to: var5-var3-var4)&lt;/P&gt;&lt;P&gt;- I believe I need to use the MDY function; but the SAS examples are not easily understood (again, being a new user!) &lt;/P&gt;&lt;P&gt;4. Calculate time since exposure (TimeSinceExp=var2-var6/365.25) with an output in Years, rounded to a single decimal (e.g. 5.4 years) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any assistance would be appreciated. I am pondering this away today and will check in tomorrow to see how close (or far off!) my own code is....so far about 20% of my more complicated coding works (which I would say isn't too bad for 2nd week of use). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best &amp;amp; many thanks in advance. &lt;/P&gt;&lt;P&gt;-Tyler &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Jun 2014 16:00:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/MDY-datdiff-functions-longitudinal-data-set/m-p/136190#M1880</guid>
      <dc:creator>toneill</dc:creator>
      <dc:date>2014-06-10T16:00:05Z</dc:date>
    </item>
    <item>
      <title>Re: MDY &amp; datdiff functions (longitudinal data set)</title>
      <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/MDY-datdiff-functions-longitudinal-data-set/m-p/136191#M1881</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;1. Only analyse those individuals at baseline who responded "YES(1)" to var2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any of the SAS procedures will allow subsetting the data either with a separate Where clause i.e.&lt;/P&gt;&lt;P&gt;proc means data=have;&lt;/P&gt;&lt;P&gt;where var2 = 1;&lt;/P&gt;&lt;P&gt;&amp;lt;other code&amp;gt;&lt;/P&gt;&lt;P&gt;or subsetting on the data set;&lt;/P&gt;&lt;P&gt;proc means data=have (where=(var2=1)) ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. Assign/impute the middle of each month (e.g. 15th day) as a new variable to every individual (create: var5)&lt;/P&gt;&lt;P&gt;Var5 = 15;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. Create a new variable: 'DateExp' (var6) -- this will combine var3-5 in to a single variable represented as: DDMMYYY (equivalent to: var5-var3-var4)&lt;/P&gt;&lt;P&gt;var6 = mdy(var3, var5, var4); (or DateExp = mdy(vare,var5,var4);&lt;/P&gt;&lt;P&gt;format var6 mmddyy10. ; /* this so the date will look like a date*/&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Actually if you are not going to use the VAR5 for anything since it represents a fixed value, skip the var5 part&lt;/P&gt;&lt;P&gt;var6= mdy(var3,15,var4);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4. Calculate time since exposure (TimeSinceExp=var2-var6/365.25) with an output in Years, rounded to a single decimal (e.g. 5.4 years) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TimeSinceExp= round ( (var2-var6)/365.25, .1);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would strongly recommend using variable names that mean something, Month instead of Var3, Year instead of Var4 DateExp instead of Var6 and/or assiging labels.&lt;/P&gt;&lt;P&gt;label DateExp = 'Date of exposure';&lt;/P&gt;&lt;P&gt;label TimeSinceExp = 'Years since exposure';&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Jun 2014 16:49:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/MDY-datdiff-functions-longitudinal-data-set/m-p/136191#M1881</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-06-10T16:49:23Z</dc:date>
    </item>
    <item>
      <title>Re: MDY &amp; datdiff functions (longitudinal data set)</title>
      <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/MDY-datdiff-functions-longitudinal-data-set/m-p/136192#M1882</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes - I plan to use alternative names; I just used them as there is some privacy issues regarding the data, so needed to be "general"! Thanks again. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Jun 2014 17:13:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/MDY-datdiff-functions-longitudinal-data-set/m-p/136192#M1882</guid>
      <dc:creator>toneill</dc:creator>
      <dc:date>2014-06-10T17:13:28Z</dc:date>
    </item>
  </channel>
</rss>

