<?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: Converting column of numeric variables to date in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Converting-column-of-numeric-variables-to-date/m-p/565826#M11252</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  TransactionDate=20190101;
  sas_date=input(put(TransactionDate,yymmdd8.),yymmdd8.);
  format sas_date date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 13 Jun 2019 12:57:34 GMT</pubDate>
    <dc:creator>VDD</dc:creator>
    <dc:date>2019-06-13T12:57:34Z</dc:date>
    <item>
      <title>Converting column of numeric variables to date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Converting-column-of-numeric-variables-to-date/m-p/565823#M11251</link>
      <description>&lt;P&gt;I have a column called `TransactionDate` which contains numbers that represent dates in the format '20190101' and I wish to convert it to date format. The code I have used is as such:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;INPUT(put(TransactionDate,8.),yymmdd8.) AS TransactionDate FORMAT ddmmyy10.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This has not worked and I am fairly new to SAS. Could someone help me out here please.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2019 12:49:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Converting-column-of-numeric-variables-to-date/m-p/565823#M11251</guid>
      <dc:creator>geds133</dc:creator>
      <dc:date>2019-06-13T12:49:51Z</dc:date>
    </item>
    <item>
      <title>Re: Converting column of numeric variables to date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Converting-column-of-numeric-variables-to-date/m-p/565826#M11252</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  TransactionDate=20190101;
  sas_date=input(put(TransactionDate,yymmdd8.),yymmdd8.);
  format sas_date date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Jun 2019 12:57:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Converting-column-of-numeric-variables-to-date/m-p/565826#M11252</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2019-06-13T12:57:34Z</dc:date>
    </item>
    <item>
      <title>Re: Converting column of numeric variables to date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Converting-column-of-numeric-variables-to-date/m-p/565828#M11253</link>
      <description>&lt;P&gt;Hi and welcome to the SAS Communities.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jsut to be clear,&amp;nbsp;TransactionDate is a character variable?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In that case do&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
    TransactionDate='20190101';
    numTransactionDate=input(TransactionDate, yymmdd8.);
    format numTransactionDate ddmmyy10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Jun 2019 13:00:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Converting-column-of-numeric-variables-to-date/m-p/565828#M11253</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-06-13T13:00:19Z</dc:date>
    </item>
    <item>
      <title>Re: Converting column of numeric variables to date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Converting-column-of-numeric-variables-to-date/m-p/565829#M11254</link>
      <description>&lt;P&gt;Please post your log (use the {i} button for this, as it keeps the original formatting of the log).&lt;/P&gt;
&lt;P&gt;If your data is as you stated, your code works:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input transactiondate;
datalines;
20190101
;

proc sql;
select
INPUT(put(TransactionDate,8.),yymmdd8.) AS TransactionDate FORMAT ddmmyy10.
from have;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;  Transaction
         Date
 ------------
   01/01/2019
&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Jun 2019 13:00:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Converting-column-of-numeric-variables-to-date/m-p/565829#M11254</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-06-13T13:00:29Z</dc:date>
    </item>
    <item>
      <title>Re: Converting column of numeric variables to date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Converting-column-of-numeric-variables-to-date/m-p/565831#M11255</link>
      <description>&lt;P&gt;Are you sure it is not already a date that just uses the YYMMDDN8.&amp;nbsp; to display it that way?&amp;nbsp; Or a character variable?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What does proc contents show for that variable?&amp;nbsp; Is it character or numeric?&amp;nbsp; Does it have a format attached?&amp;nbsp; Remember that SAS only had two data types, fixed length strings and floating point numbers.&amp;nbsp; Dates are stored as the number of days since 1960 and only appear like dates to humans when a date type format is used.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2019 13:05:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Converting-column-of-numeric-variables-to-date/m-p/565831#M11255</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-06-13T13:05:18Z</dc:date>
    </item>
    <item>
      <title>Re: Converting column of numeric variables to date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Converting-column-of-numeric-variables-to-date/m-p/565859#M11262</link>
      <description>&lt;P&gt;Is it a numeric variable column, not in date format.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2019 14:36:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Converting-column-of-numeric-variables-to-date/m-p/565859#M11262</guid>
      <dc:creator>geds133</dc:creator>
      <dc:date>2019-06-13T14:36:29Z</dc:date>
    </item>
    <item>
      <title>Re: Converting column of numeric variables to date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Converting-column-of-numeric-variables-to-date/m-p/565860#M11263</link>
      <description>&lt;P&gt;This simply returns a single date instead of turning the whole column into dates.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2019 14:37:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Converting-column-of-numeric-variables-to-date/m-p/565860#M11263</guid>
      <dc:creator>geds133</dc:creator>
      <dc:date>2019-06-13T14:37:34Z</dc:date>
    </item>
    <item>
      <title>Re: Converting column of numeric variables to date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Converting-column-of-numeric-variables-to-date/m-p/565861#M11264</link>
      <description>&lt;P&gt;I am looking to turn the column into date format not just a singular number.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2019 14:38:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Converting-column-of-numeric-variables-to-date/m-p/565861#M11264</guid>
      <dc:creator>geds133</dc:creator>
      <dc:date>2019-06-13T14:38:25Z</dc:date>
    </item>
    <item>
      <title>Re: Converting column of numeric variables to date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Converting-column-of-numeric-variables-to-date/m-p/565862#M11265</link>
      <description>&lt;P&gt;TransactionDate is a numeric column&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2019 14:39:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Converting-column-of-numeric-variables-to-date/m-p/565862#M11265</guid>
      <dc:creator>geds133</dc:creator>
      <dc:date>2019-06-13T14:39:17Z</dc:date>
    </item>
    <item>
      <title>Re: Converting column of numeric variables to date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Converting-column-of-numeric-variables-to-date/m-p/565872#M11269</link>
      <description>&lt;P&gt;Your example code should work as PART of a larger SELECT statement inside of PROC SQL.&lt;/P&gt;
&lt;P&gt;Please show the code you actually ran. If you got ERRORS from SAS show the LOG.&amp;nbsp; If you got the wrong result explain how it was wrong.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2019 14:58:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Converting-column-of-numeric-variables-to-date/m-p/565872#M11269</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-06-13T14:58:34Z</dc:date>
    </item>
    <item>
      <title>Re: Converting column of numeric variables to date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Converting-column-of-numeric-variables-to-date/m-p/565891#M11274</link>
      <description>&lt;P&gt;`proc sql;&lt;BR /&gt;CREATE TABLE WORK.twentyeighteen AS&lt;BR /&gt;SELECT&lt;BR /&gt;a.*,&lt;BR /&gt;INPUT(put(TransactionDate,8.),yymmdd8.) AS TransactionDate format ddmmyy10.&lt;BR /&gt;FROM&lt;BR /&gt;database.td AS a&lt;BR /&gt;WHERE&lt;BR /&gt;TransactionDate &amp;gt; 20180101;&lt;BR /&gt;quit;`&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;CREATE TABLE WORK.trans AS&lt;BR /&gt;SELECT&lt;BR /&gt;SUM(CashValue + ChequeValue + TransferValue) as TotalDeposit,&lt;BR /&gt;MONTH(TransactionDate) AS month&lt;BR /&gt;FROM&lt;BR /&gt;WORK.twentyeighteen&lt;BR /&gt;WHERE&lt;BR /&gt;TransactionCode = 1&amp;nbsp;&lt;BR /&gt;GROUP BY&lt;BR /&gt;month&lt;BR /&gt;ORDER BY&lt;BR /&gt;month;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don'y receive any errors but the result is only a single row instead of a list of deposits per month&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2019 15:30:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Converting-column-of-numeric-variables-to-date/m-p/565891#M11274</guid>
      <dc:creator>geds133</dc:creator>
      <dc:date>2019-06-13T15:30:06Z</dc:date>
    </item>
    <item>
      <title>Re: Converting column of numeric variables to date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Converting-column-of-numeric-variables-to-date/m-p/565893#M11275</link>
      <description>&lt;P&gt;proc sql;&lt;BR /&gt;CREATE TABLE WORK.twentyeighteen AS&lt;BR /&gt;SELECT&lt;BR /&gt;a.*,&lt;BR /&gt;INPUT(put(TransactionDate,8.),yymmdd8.) AS TransactionDate format ddmmyy10.&lt;BR /&gt;FROM&lt;BR /&gt;database.td AS a&lt;BR /&gt;WHERE&lt;BR /&gt;TransactionDate &amp;gt; 20180101;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;CREATE TABLE WORK.trans AS&lt;BR /&gt;SELECT&lt;BR /&gt;SUM(CashValue + ChequeValue + TransferValue) as TotalDeposit,&lt;BR /&gt;MONTH(TransactionDate) AS month&lt;BR /&gt;FROM&lt;BR /&gt;WORK.twentyeighteen&lt;BR /&gt;WHERE&lt;BR /&gt;TransactionCode = 1&amp;nbsp;&lt;BR /&gt;GROUP BY&lt;BR /&gt;month&lt;BR /&gt;ORDER BY&lt;BR /&gt;month;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don'y receive any errors but the result is only a single row instead of a list of deposits per month&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2019 15:31:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Converting-column-of-numeric-variables-to-date/m-p/565893#M11275</guid>
      <dc:creator>geds133</dc:creator>
      <dc:date>2019-06-13T15:31:03Z</dc:date>
    </item>
    <item>
      <title>Re: Converting column of numeric variables to date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Converting-column-of-numeric-variables-to-date/m-p/565933#M11277</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/277796"&gt;@geds133&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am looking to turn the column into date format not just a singular number.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Utterly wrong. It will convert ALL values of column transactiondate in the "from" dataset. That my example dataset contains only one observation is because I did not want to waste time unnecessarily and am a lazy person by nature.&lt;/P&gt;
&lt;P&gt;I strongly suggest that you work through the free online Programming 1 course to get a grasp of the most basic principles of SAS programming, so you don't fall victim to misunderstandings as happened above.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2019 17:07:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Converting-column-of-numeric-variables-to-date/m-p/565933#M11277</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-06-13T17:07:56Z</dc:date>
    </item>
    <item>
      <title>Re: Converting column of numeric variables to date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Converting-column-of-numeric-variables-to-date/m-p/565936#M11278</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/277796"&gt;@geds133&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;`proc sql;&lt;BR /&gt;CREATE TABLE WORK.twentyeighteen AS&lt;BR /&gt;SELECT&lt;BR /&gt;a.*,&lt;BR /&gt;INPUT(put(TransactionDate,8.),yymmdd8.) AS TransactionDate format ddmmyy10.&lt;BR /&gt;FROM&lt;BR /&gt;database.td AS a&lt;BR /&gt;WHERE&lt;BR /&gt;TransactionDate &amp;gt; 20180101;&lt;BR /&gt;quit;`&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;CREATE TABLE WORK.trans AS&lt;BR /&gt;SELECT&lt;BR /&gt;SUM(CashValue + ChequeValue + TransferValue) as TotalDeposit,&lt;BR /&gt;MONTH(TransactionDate) AS month&lt;BR /&gt;FROM&lt;BR /&gt;WORK.twentyeighteen&lt;BR /&gt;WHERE&lt;BR /&gt;TransactionCode = 1&amp;nbsp;&lt;BR /&gt;GROUP BY&lt;BR /&gt;month&lt;BR /&gt;ORDER BY&lt;BR /&gt;month;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don'y receive any errors but the result is only a single row instead of a list of deposits per month&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Run a proc freq on column month in dataset twentyeighteen with the same where condition (transactioncode = 1); I suspect you only have one distinct value there.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2019 17:11:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Converting-column-of-numeric-variables-to-date/m-p/565936#M11278</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-06-13T17:11:32Z</dc:date>
    </item>
    <item>
      <title>Re: Converting column of numeric variables to date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Converting-column-of-numeric-variables-to-date/m-p/566516#M11364</link>
      <description>&lt;P&gt;The month column does not exist in twentyeighteen. I create this variable in the next instance of CREATE TABLE.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jun 2019 09:28:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Converting-column-of-numeric-variables-to-date/m-p/566516#M11364</guid>
      <dc:creator>geds133</dc:creator>
      <dc:date>2019-06-17T09:28:21Z</dc:date>
    </item>
    <item>
      <title>Re: Converting column of numeric variables to date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Converting-column-of-numeric-variables-to-date/m-p/566517#M11365</link>
      <description>&lt;P&gt;Then run the SQL without the group by, and then the proc freq over month.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jun 2019 09:43:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Converting-column-of-numeric-variables-to-date/m-p/566517#M11365</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-06-17T09:43:21Z</dc:date>
    </item>
  </channel>
</rss>

