<?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 date formats in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/date-formats/m-p/244708#M45626</link>
    <description>&lt;P&gt;I have 2 datasets one has subject with start_date and other with subject with few missing first drug date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to get the start_date of first dataset if my second dataset first drug date is missing(only if missing), else use the same one.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;can any one help me in this. i am using the below code but not wiorking&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt; create table subj_dose2 as&lt;BR /&gt; select distinct trl_id&lt;BR /&gt; , subj_id&lt;BR /&gt; ,src_start_dt&lt;BR /&gt; from ddm.subj_comp_dos&lt;BR /&gt; where topic_cd in ("BIASP")&lt;BR /&gt; and dose &amp;gt; 0&lt;BR /&gt; order by trl_id&lt;BR /&gt; , subj_id&lt;BR /&gt; ,src_start_dt;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;proc sort data=ddm.subj out=subj_tmp;&lt;BR /&gt; by trl_id subj_id;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;***Update exposed flag in ddm.subj***;&lt;BR /&gt;data subj(drop=src_start_dt);&lt;BR /&gt; merge subj_tmp(in=subj)&lt;BR /&gt; subj_dose2(in=dose2);&lt;BR /&gt; by trl_id subj_id;&lt;BR /&gt; if subj;&lt;BR /&gt; if fdrg_dt ne . then do;&lt;BR /&gt; rename src_start_dt=fdrg;&lt;BR /&gt; end;&lt;BR /&gt;run;&lt;/P&gt;</description>
    <pubDate>Wed, 20 Jan 2016 15:02:44 GMT</pubDate>
    <dc:creator>vraj1</dc:creator>
    <dc:date>2016-01-20T15:02:44Z</dc:date>
    <item>
      <title>date formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-formats/m-p/244708#M45626</link>
      <description>&lt;P&gt;I have 2 datasets one has subject with start_date and other with subject with few missing first drug date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to get the start_date of first dataset if my second dataset first drug date is missing(only if missing), else use the same one.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;can any one help me in this. i am using the below code but not wiorking&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt; create table subj_dose2 as&lt;BR /&gt; select distinct trl_id&lt;BR /&gt; , subj_id&lt;BR /&gt; ,src_start_dt&lt;BR /&gt; from ddm.subj_comp_dos&lt;BR /&gt; where topic_cd in ("BIASP")&lt;BR /&gt; and dose &amp;gt; 0&lt;BR /&gt; order by trl_id&lt;BR /&gt; , subj_id&lt;BR /&gt; ,src_start_dt;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;proc sort data=ddm.subj out=subj_tmp;&lt;BR /&gt; by trl_id subj_id;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;***Update exposed flag in ddm.subj***;&lt;BR /&gt;data subj(drop=src_start_dt);&lt;BR /&gt; merge subj_tmp(in=subj)&lt;BR /&gt; subj_dose2(in=dose2);&lt;BR /&gt; by trl_id subj_id;&lt;BR /&gt; if subj;&lt;BR /&gt; if fdrg_dt ne . then do;&lt;BR /&gt; rename src_start_dt=fdrg;&lt;BR /&gt; end;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jan 2016 15:02:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-formats/m-p/244708#M45626</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2016-01-20T15:02:44Z</dc:date>
    </item>
    <item>
      <title>Re: date formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-formats/m-p/244714#M45629</link>
      <description>&lt;P&gt;Posting test data in the form of a datastep would help. &amp;nbsp;At a guess something like:&lt;/P&gt;
&lt;PRE&gt;proc sql;
  create table WANT as
  select  A.TRT_ID,
            A.SUBJID,
            coalesce(A.DRUG_DATE,B.START_DATE) as DRUG_DATE
  from    HAVE A
  left join START_DATES B
  on       A.SUBJID=B.SUBJID;
quit;&lt;/PRE&gt;
&lt;P&gt;The coalesce() function takes the first non-missing from the list of variables. &amp;nbsp;The same logic works in datastep.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jan 2016 15:12:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-formats/m-p/244714#M45629</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-01-20T15:12:43Z</dc:date>
    </item>
    <item>
      <title>Re: date formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-formats/m-p/244718#M45633</link>
      <description>&lt;P&gt;The RENAME statement is a declarative statement. Hence, you can't execute it conditionally (with IF/THEN). Its purpose is to change variable names, not to transfer values from one variable to another.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To&amp;nbsp;impute a missing value of variable X with the value of variable Y in the same observation (without overwriting non-missing values of X), you can use a conditional &lt;EM&gt;assignment&lt;/EM&gt; statement like&amp;nbsp;&lt;FONT face="courier new,courier"&gt;if x=. then x=y; &lt;FONT face="arial,helvetica,sans-serif"&gt;(but there are alternative approaches as well, see&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9﻿&lt;/a&gt;'s post).&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jan 2016 15:32:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-formats/m-p/244718#M45633</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-01-20T15:32:47Z</dc:date>
    </item>
    <item>
      <title>Re: date formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-formats/m-p/244898#M45682</link>
      <description>&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;But in this case the drug date is in date9.(numeric) and start date is in char.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i get the below error&lt;/P&gt;
&lt;P&gt;ERROR: The COALESCE function requires its arguments to be of the same data type.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jan 2016 08:50:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-formats/m-p/244898#M45682</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2016-01-21T08:50:16Z</dc:date>
    </item>
    <item>
      <title>Re: date formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-formats/m-p/244904#M45683</link>
      <description>&lt;P&gt;You will of coursehave to change any code to match your data as you didn't supply any. &amp;nbsp;Depending on what you want the output variable type to be:&lt;/P&gt;
&lt;P&gt;Numeric&lt;/P&gt;
&lt;PRE&gt;coalesce(A.DRUG_DATE,input(B.START_DATE,date9.)) as DRUG_DATE&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Char&lt;/P&gt;
&lt;PRE&gt;coalesce(put(A.DRUG_DATE,date9.),B.START_DATE) as DRUG_DATE&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jan 2016 09:27:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-formats/m-p/244904#M45683</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-01-21T09:27:37Z</dc:date>
    </item>
  </channel>
</rss>

