<?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: Inserting date value using &amp;quot;Insert into&amp;quot; in PROC SQL when the date has MMDDYYw. format in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Inserting-date-value-using-quot-Insert-into-quot-in-PROC-SQL/m-p/360372#M64419</link>
    <description>&lt;P&gt;Well, this depends on what the informat is for the variable in question. &amp;nbsp;If your data is expecting mmddyy format and you are supplying ddmmyy format then it will not work. &amp;nbsp;Can you post test data from your existing dataset, as a datstep so I don't have to guess. &amp;nbsp;You could also save yourself a lot of time by doing:&lt;/P&gt;
&lt;PRE&gt;data want;
  set work.sales_data2;
  informat ...;
  input...;

datalines;
...
;
run;&lt;/PRE&gt;</description>
    <pubDate>Mon, 22 May 2017 07:55:33 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2017-05-22T07:55:33Z</dc:date>
    <item>
      <title>Inserting date value using "Insert into" in PROC SQL when the date has MMDDYYw. format</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Inserting-date-value-using-quot-Insert-into-quot-in-PROC-SQL/m-p/360366#M64418</link>
      <description>&lt;P&gt;I am trying to add some new rows to an existing data file using proc sql/insert into. As you can see from the data format that the dates are in MMDDYY format. When I am inputing 120111 (12 January 2011) in the values statement I am getting this &lt;U&gt;&lt;STRONG&gt;"11/07/2288"&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;in the output which clearly wrong. I want to know what is the right way to specify the "date" in this situation ? Attached the code and the data file below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My data set looks like this&amp;nbsp;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/8980i1570989B63267954/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="Screen Shot 2017-05-22 at 2.07.14 AM.png" title="Screen Shot 2017-05-22 at 2.07.14 AM.png" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to insert 4 new rows using following code&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.sales_data2;
set work.example;
run;

proc sql;
insert into work.sales_data2 
VALUES(120111,120111,1244118000,11100,"Orange_Juice", 2,4,32.80)
VALUES(120211,120211,1244118001,11101,"Chocolate",3,2,18.20 )
VALUES(120311,120311,1244118002,11102,"Candy",1,5,3.00 )
VALUES(120411,120411,1244118003,11103,"Orange_Juice",1,5,35.00 );
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The output looks like this . But the date is not showing the desired format- which is supposed to&amp;nbsp;be 12/01/11&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/8981i84BD6554C3DB8D51/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="Screen Shot 2017-05-22 at 2.20.47 AM.png" title="Screen Shot 2017-05-22 at 2.20.47 AM.png" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;-----------------------------------------------------------&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Updating the post with final solution. Find the code below. (Thanks to&amp;nbsp;&lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562" target="_self"&gt;&lt;SPAN class="login-bold"&gt;KurtBremser&lt;/SPAN&gt;&lt;/A&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.sales_data2;
set work.example;
format Order_date mmddyy10.;
format Delivery_date mmddyy10.;
run;

proc sql;
insert into work.sales_data2 
VALUES("01dec2011"d,"01dec2011"d,1244118000,11100,"Orange_Juice", 2,4,32.80);
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The correct steps to follow are:&lt;/P&gt;&lt;P&gt;1. check the format of date values (in the original data set) using describe table&lt;/P&gt;&lt;P&gt;2. use format statement within the data step to ensure the new value added will be&amp;nbsp;in proper format.&lt;/P&gt;&lt;P&gt;3. finally, use date literal (with quotation and d at the end) in your values statement to ensure that the dates are read properly.&lt;/P&gt;</description>
      <pubDate>Mon, 22 May 2017 16:27:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Inserting-date-value-using-quot-Insert-into-quot-in-PROC-SQL/m-p/360366#M64418</guid>
      <dc:creator>shihabur</dc:creator>
      <dc:date>2017-05-22T16:27:11Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting date value using "Insert into" in PROC SQL when the date has MMDDYYw. format</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Inserting-date-value-using-quot-Insert-into-quot-in-PROC-SQL/m-p/360372#M64419</link>
      <description>&lt;P&gt;Well, this depends on what the informat is for the variable in question. &amp;nbsp;If your data is expecting mmddyy format and you are supplying ddmmyy format then it will not work. &amp;nbsp;Can you post test data from your existing dataset, as a datstep so I don't have to guess. &amp;nbsp;You could also save yourself a lot of time by doing:&lt;/P&gt;
&lt;PRE&gt;data want;
  set work.sales_data2;
  informat ...;
  input...;

datalines;
...
;
run;&lt;/PRE&gt;</description>
      <pubDate>Mon, 22 May 2017 07:55:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Inserting-date-value-using-quot-Insert-into-quot-in-PROC-SQL/m-p/360372#M64419</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-05-22T07:55:33Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting date value using "Insert into" in PROC SQL when the date has MMDDYYw. format</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Inserting-date-value-using-quot-Insert-into-quot-in-PROC-SQL/m-p/360392#M64420</link>
      <description>&lt;P&gt;When you want to set a SAS date variable with a numeric value, you need to supply it as a date literal, or you have to convert to the correct SAS date value before.&lt;/P&gt;
&lt;P&gt;The raw value 120111 is the SAS date 11/07/2288 (120111 days since 1960-01-01).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
format x1 yymmddd10.;
x1 = today();
run;

proc sql;
insert into test
values("12jan2011"d)
;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 22 May 2017 09:14:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Inserting-date-value-using-quot-Insert-into-quot-in-PROC-SQL/m-p/360392#M64420</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-05-22T09:14:01Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting date value using "Insert into" in PROC SQL when the date has MMDDYYw. format</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Inserting-date-value-using-quot-Insert-into-quot-in-PROC-SQL/m-p/360393#M64421</link>
      <description>&lt;P&gt;BTW DO NOT supply example data in an Excel file. An Excel file&lt;/P&gt;
&lt;P&gt;- is considered malware by most corporate firewalls and therefore blocked (also see the recent flap with ransom trojans)&lt;/P&gt;
&lt;P&gt;- can not convey atttributes of dataset and columns&lt;/P&gt;
&lt;P&gt;and therefore useless.&lt;/P&gt;
&lt;P&gt;Write a data step that creates your example data, see my code.&lt;/P&gt;</description>
      <pubDate>Mon, 22 May 2017 09:16:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Inserting-date-value-using-quot-Insert-into-quot-in-PROC-SQL/m-p/360393#M64421</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-05-22T09:16:47Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting date value using "Insert into" in PROC SQL when the date has MMDDYYw. format</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Inserting-date-value-using-quot-Insert-into-quot-in-PROC-SQL/m-p/360473#M64423</link>
      <description>&lt;P&gt;I have replaced the excel file with a&amp;nbsp;sas7bdat file.&lt;/P&gt;</description>
      <pubDate>Mon, 22 May 2017 15:46:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Inserting-date-value-using-quot-Insert-into-quot-in-PROC-SQL/m-p/360473#M64423</guid>
      <dc:creator>shihabur</dc:creator>
      <dc:date>2017-05-22T15:46:56Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting date value using "Insert into" in PROC SQL when the date has MMDDYYw. format</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Inserting-date-value-using-quot-Insert-into-quot-in-PROC-SQL/m-p/360475#M64424</link>
      <description>&lt;P&gt;proc sql describe table shows that -&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="sasSource"&gt;Order_Date num format=MMDDYY10. label='Date Order was placed by Customer',&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;Delivery_Date num format=DATE9. label='Date Order was Delivered',&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;posting the test data as data step in a bit.&lt;/DIV&gt;</description>
      <pubDate>Mon, 22 May 2017 15:50:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Inserting-date-value-using-quot-Insert-into-quot-in-PROC-SQL/m-p/360475#M64424</guid>
      <dc:creator>shihabur</dc:creator>
      <dc:date>2017-05-22T15:50:24Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting date value using "Insert into" in PROC SQL when the date has MMDDYYw. format</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Inserting-date-value-using-quot-Insert-into-quot-in-PROC-SQL/m-p/360481#M64425</link>
      <description>&lt;P&gt;This works. Thanks a lot. I understand what I was doing wrong.&lt;/P&gt;</description>
      <pubDate>Mon, 22 May 2017 16:20:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Inserting-date-value-using-quot-Insert-into-quot-in-PROC-SQL/m-p/360481#M64425</guid>
      <dc:creator>shihabur</dc:creator>
      <dc:date>2017-05-22T16:20:16Z</dc:date>
    </item>
  </channel>
</rss>

