<?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: note: invalid argument to function qtr. missing values may be generated in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/note-invalid-argument-to-function-qtr-missing-values-may-be/m-p/429127#M68540</link>
    <description>&lt;P&gt;And what does var1, var2 etc. contain?&amp;nbsp; Show some test data in the form of a datastep using the code window = {i} above post area and following this post if needed:&lt;/P&gt;
&lt;P&gt;&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;&lt;/P&gt;
&lt;P&gt;The first two notes are telling you that var1 or var2 contain data which is missing or invalid, and hence a missing value is returned.&lt;/P&gt;</description>
    <pubDate>Fri, 19 Jan 2018 14:20:23 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2018-01-19T14:20:23Z</dc:date>
    <item>
      <title>note: invalid argument to function qtr. missing values may be generated</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/note-invalid-argument-to-function-qtr-missing-values-may-be/m-p/429120#M68539</link>
      <description>&lt;P&gt;hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to convert some dates to quarters and week days as well as calculating length of stay with them using proc sql. I have used the code before and it's worked but today it's been giving me the following&amp;nbsp;notes:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/17972i547447CA37318074/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;below is a sample of the code that I've been using and my formats:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style="font-family: 'Calibri',sans-serif;"&gt;proc&lt;/SPAN&gt;&lt;/STRONG&gt; &lt;STRONG&gt;&lt;SPAN style="font-family: 'Calibri',sans-serif;"&gt;sql&lt;/SPAN&gt;&lt;/STRONG&gt;; create table&amp;nbsp;NEW as&lt;/P&gt;&lt;P&gt;select a.*,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case when VAR='88'&amp;nbsp; then &lt;STRONG&gt;&lt;SPAN style="font-family: 'Calibri',sans-serif;"&gt;1&lt;/SPAN&gt;&lt;/STRONG&gt; else &lt;STRONG&gt;&lt;SPAN style="font-family: 'Calibri',sans-serif;"&gt;0&lt;/SPAN&gt;&lt;/STRONG&gt; end as CAT,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; put(qtr(VAR1), qr.) as a_qtr,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;put(qtr(VAR2), qr.) as d_qtr,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; put(weekday(VAR1), wk.) as a_day,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; intck('DAY',VAR2,VAR1) as c_los,&lt;/P&gt;&lt;P&gt;from&amp;nbsp;OLD a&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style="font-family: 'Calibri',sans-serif;"&gt;quit&lt;/SPAN&gt;&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;value&amp;nbsp;wk&lt;BR /&gt;1='SUN'&lt;BR /&gt;2='MON'&lt;BR /&gt;3='TUE'&lt;BR /&gt;4='WED'&lt;BR /&gt;5='THU'&lt;BR /&gt;6='FRI'&lt;BR /&gt;7='SAT'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;value qr&lt;BR /&gt;1='Jan-Mar'&lt;BR /&gt;2='Apr-Jun'&lt;BR /&gt;3='Jul-Sep'&lt;BR /&gt;4='Oct-Dec'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What am I doing wrong??&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jan 2018 14:09:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/note-invalid-argument-to-function-qtr-missing-values-may-be/m-p/429120#M68539</guid>
      <dc:creator>lupegon34</dc:creator>
      <dc:date>2018-01-19T14:09:39Z</dc:date>
    </item>
    <item>
      <title>Re: note: invalid argument to function qtr. missing values may be generated</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/note-invalid-argument-to-function-qtr-missing-values-may-be/m-p/429127#M68540</link>
      <description>&lt;P&gt;And what does var1, var2 etc. contain?&amp;nbsp; Show some test data in the form of a datastep using the code window = {i} above post area and following this post if needed:&lt;/P&gt;
&lt;P&gt;&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;&lt;/P&gt;
&lt;P&gt;The first two notes are telling you that var1 or var2 contain data which is missing or invalid, and hence a missing value is returned.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jan 2018 14:20:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/note-invalid-argument-to-function-qtr-missing-values-may-be/m-p/429127#M68540</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-01-19T14:20:23Z</dc:date>
    </item>
    <item>
      <title>Re: note: invalid argument to function qtr. missing values may be generated</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/note-invalid-argument-to-function-qtr-missing-values-may-be/m-p/429133#M68541</link>
      <description>&lt;P&gt;These functions expect SAS date values as arguments; these are numeric and contain the count of days since 1960-01-01.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jan 2018 14:29:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/note-invalid-argument-to-function-qtr-missing-values-may-be/m-p/429133#M68541</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-01-19T14:29:02Z</dc:date>
    </item>
    <item>
      <title>Re: note: invalid argument to function qtr. missing values may be generated</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/note-invalid-argument-to-function-qtr-missing-values-may-be/m-p/429134#M68542</link>
      <description>&lt;P&gt;They are both numeric variables and contain dates with the date9. format applied to them.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So for example, I have 20160103 20160104 20160105. I want to be able to create quarters and specify what day of the week it is from these dates. Then I wanted to apply a specific format&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jan 2018 14:41:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/note-invalid-argument-to-function-qtr-missing-values-may-be/m-p/429134#M68542</guid>
      <dc:creator>lupegon34</dc:creator>
      <dc:date>2018-01-19T14:41:29Z</dc:date>
    </item>
    <item>
      <title>Re: note: invalid argument to function qtr. missing values may be generated</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/note-invalid-argument-to-function-qtr-missing-values-may-be/m-p/429139#M68543</link>
      <description>&lt;P&gt;Please post examples as requested.&amp;nbsp; If you really have numeric date variables and are passing those, then main check I would make is that there aren't observations with missing values, as missing value is invalid.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jan 2018 14:39:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/note-invalid-argument-to-function-qtr-missing-values-may-be/m-p/429139#M68543</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-01-19T14:39:33Z</dc:date>
    </item>
    <item>
      <title>Re: note: invalid argument to function qtr. missing values may be generated</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/note-invalid-argument-to-function-qtr-missing-values-may-be/m-p/429141#M68544</link>
      <description>&lt;P&gt;Testing always beats speculating:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data old;
var1 = today();
var2 = 123456789;
var3 = .;
run;

proc sql;
create table new1 as
select
  qtr(var1) as var1x
from old
;
create table new2 as
select
  qtr(var2) as var2x
from old
;
create table new3 as
select
  qtr(var3) as var3x
from old
;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Log from that:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;24         data old;
25         var1 = today();
26         var2 = 123456789;
27         var3 = .;
28         run;

NOTE: The data set WORK.OLD has 1 observations and 3 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds
      

29         
30         proc sql;
31         create table new1 as
32         select
33           qtr(var1) as var1x
34         from old
35         ;
NOTE: Table WORK.NEW1 created, with 1 rows and 1 columns.

36         create table new2 as
37         select
38           qtr(var2) as var2x
39         from old
40         ;
NOTE: Invalid argument to function QTR. Missing values may be generated.
NOTE: Table WORK.NEW2 created, with 1 rows and 1 columns.

41         create table new3 as
42         select
43           qtr(var3) as var3x
44         from old
45         ;
2                                                          Das SAS System                             15:35 Friday, January 19, 2018

NOTE: Invalid (or missing) arguments to the QTR function have caused the function to return a missing value.
NOTE: Table WORK.NEW3 created, with 1 rows and 1 columns.

46         quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that the second value causes the same message you encountered, so you have a numeric value that is outside of the range of valid values for SAS dates. Are you sure it isn't a datetime value instead of a date?&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jan 2018 14:41:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/note-invalid-argument-to-function-qtr-missing-values-may-be/m-p/429141#M68544</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-01-19T14:41:44Z</dc:date>
    </item>
    <item>
      <title>Re: note: invalid argument to function qtr. missing values may be generated</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/note-invalid-argument-to-function-qtr-missing-values-may-be/m-p/429145#M68545</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/147762"&gt;@lupegon34&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;They are both numeric variables and contain dates with the date9. format applied to them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So for example, I have 20160103 20160104 20160105. I want to be able to create quarters and specify what day of the week it is from these dates. Then I wanted to apply a specific format&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Ouch. A numeric value of 20160103 is not a SAS date value. If it was a SAS date value formatted with date9., it would display as 03jan2016.&lt;/P&gt;
&lt;P&gt;But the raw value 20160103 would cause exactly your error message when used in a date-related function (see my other answer).&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jan 2018 14:44:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/note-invalid-argument-to-function-qtr-missing-values-may-be/m-p/429145#M68545</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-01-19T14:44:47Z</dc:date>
    </item>
    <item>
      <title>Re: note: invalid argument to function qtr. missing values may be generated</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/note-invalid-argument-to-function-qtr-missing-values-may-be/m-p/429151#M68546</link>
      <description>&lt;P&gt;You know, shortly after I posted that I was like "wait a minute .....". lol.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Apparently all the date variables had been incorrectly formatted due to&amp;nbsp;my company moving over to a new database. So of course, now everything has to be reformatted. *face palm*&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I appreciate your help!&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jan 2018 15:06:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/note-invalid-argument-to-function-qtr-missing-values-may-be/m-p/429151#M68546</guid>
      <dc:creator>lupegon34</dc:creator>
      <dc:date>2018-01-19T15:06:47Z</dc:date>
    </item>
    <item>
      <title>Re: note: invalid argument to function qtr. missing values may be generated</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/note-invalid-argument-to-function-qtr-missing-values-may-be/m-p/429154#M68547</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/147762"&gt;@lupegon34&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;They are both numeric variables and contain dates with the date9. format applied to them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So for example, I have 20160103 20160104 20160105. I want to be able to create quarters and specify what day of the week it is from these dates. Then I wanted to apply a specific format&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If you have values that look like 20160103 what value do you get when you apply date9. format?&lt;/P&gt;
&lt;P&gt;If you get something similar to this for YOUR values then you have simple numeric values that are not SAS date values.&lt;/P&gt;
&lt;PRE&gt;1    data _null_;
2       x=20160103;
3       put x= date9.;
4    run;

x=*********
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The above ****** is because that value is not recognizable as a date to SAS. The current range of values that the date functions will accept ends at 31Dec20000 (yes year 20,000) which corresponds to a simple numeric value (number of days since 1JAN1960) of 6589335.&amp;nbsp;Your 20160103&amp;nbsp;is about 135570768 days past the end of valid date values.&lt;/P&gt;
&lt;P&gt;Likely to get an actual SAS date valued variable that will actually work you need to read that appropriately with something like&lt;/P&gt;
&lt;PRE&gt;data _null_;
   x=20160103;
   sasdate= input(put(x,8.),yymmdd8.);
   put sasdate date9.;

run;&lt;/PRE&gt;
&lt;P&gt;And the formats or functions will work on the sasdate variable constructed as above.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jan 2018 15:10:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/note-invalid-argument-to-function-qtr-missing-values-may-be/m-p/429154#M68547</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-01-19T15:10:22Z</dc:date>
    </item>
    <item>
      <title>Re: note: invalid argument to function qtr. missing values may be generated</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/note-invalid-argument-to-function-qtr-missing-values-may-be/m-p/429155#M68548</link>
      <description>&lt;P&gt;Thank you so much!&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jan 2018 15:14:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/note-invalid-argument-to-function-qtr-missing-values-may-be/m-p/429155#M68548</guid>
      <dc:creator>lupegon34</dc:creator>
      <dc:date>2018-01-19T15:14:12Z</dc:date>
    </item>
  </channel>
</rss>

