<?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 Copying Date Variable in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Copying-Date-Variable/m-p/824756#M35187</link>
    <description>&lt;P&gt;Hi there!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset that would be very simply formatted in the example below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID.&amp;nbsp; &amp;nbsp; Appt_Type.&amp;nbsp; &amp;nbsp; A1_Date.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;NewDate&lt;/P&gt;&lt;P&gt;1.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;01JAN2009&lt;/P&gt;&lt;P&gt;2.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;7&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 11APR 2007&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 6&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;22FEB2008&lt;/P&gt;&lt;P&gt;4.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;23AUG2004&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Essentially, I want to create a new column that copies over the date if a certain criteria regarding the appt type is met. I've been using if, then statement but cannot get the date to copy over.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i.e. If appt_type=5, then I want NewDate to equal the value in A1_Date, so NewDate would be 01JAN2009 for ID 1 and 23AUG2004 for ID 4.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Simple question, but I can't seem to find the right code &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 21 Jul 2022 19:20:25 GMT</pubDate>
    <dc:creator>rangermollie</dc:creator>
    <dc:date>2022-07-21T19:20:25Z</dc:date>
    <item>
      <title>Copying Date Variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Copying-Date-Variable/m-p/824756#M35187</link>
      <description>&lt;P&gt;Hi there!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset that would be very simply formatted in the example below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID.&amp;nbsp; &amp;nbsp; Appt_Type.&amp;nbsp; &amp;nbsp; A1_Date.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;NewDate&lt;/P&gt;&lt;P&gt;1.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;01JAN2009&lt;/P&gt;&lt;P&gt;2.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;7&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 11APR 2007&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 6&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;22FEB2008&lt;/P&gt;&lt;P&gt;4.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;23AUG2004&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Essentially, I want to create a new column that copies over the date if a certain criteria regarding the appt type is met. I've been using if, then statement but cannot get the date to copy over.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i.e. If appt_type=5, then I want NewDate to equal the value in A1_Date, so NewDate would be 01JAN2009 for ID 1 and 23AUG2004 for ID 4.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Simple question, but I can't seem to find the right code &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jul 2022 19:20:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Copying-Date-Variable/m-p/824756#M35187</guid>
      <dc:creator>rangermollie</dc:creator>
      <dc:date>2022-07-21T19:20:25Z</dc:date>
    </item>
    <item>
      <title>Re: Copying Date Variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Copying-Date-Variable/m-p/824802#M35188</link>
      <description>&lt;P&gt;"Cannot get the date to copy" is sort of vague.&lt;BR /&gt;&lt;BR /&gt;Are there errors in the log?: Post the code and log in a code box opened with the "&amp;lt;/&amp;gt;" to maintain formatting of error messages.&lt;BR /&gt;&lt;BR /&gt;No output? Post any log in a code box.&lt;BR /&gt;&lt;BR /&gt;Unexpected output? Provide input data in the form of data step code pasted into a code box, the actual results and the expected results. Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the "&amp;lt;/&amp;gt;" icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One thing that is possible that you get a value that you don't expect. If the value for Id 1 is 17898 then all you need to do is apply the DATE9. format to the value. Add the data step where you create the value.&lt;/P&gt;
&lt;PRE&gt;   Format Newdate date9.;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The basic approach would be below. If your code looks much different from this you really need to share.&lt;/P&gt;
&lt;PRE&gt;if appt_type=5 then Newdate = A1date;
/* or if appt_type is a character value*/
if appt_type='5' then Newdate = A1date;&lt;/PRE&gt;
&lt;P&gt;If you are testing multiple Appt_type values you would use an "Else" before the the comparison for a different type value.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jul 2022 23:20:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Copying-Date-Variable/m-p/824802#M35188</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-07-21T23:20:05Z</dc:date>
    </item>
    <item>
      <title>Re: Copying Date Variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Copying-Date-Variable/m-p/824811#M35189</link>
      <description>&lt;P&gt;Oh cool the date9 format worked thanks&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jul 2022 02:46:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Copying-Date-Variable/m-p/824811#M35189</guid>
      <dc:creator>rangermollie</dc:creator>
      <dc:date>2022-07-22T02:46:42Z</dc:date>
    </item>
  </channel>
</rss>

