<?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 format understanding in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Date-format-understanding/m-p/613209#M179067</link>
    <description>&lt;P&gt;Could you please help me to resolve the error?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Value of macro variable is defined as&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let REPORTINGDATE =15886;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;649        proc sql;
650           651           select CASE
652        WHEN PROFITABILITY_FLG= "" then .
653        WHEN PROFITABILITY_FLG= "O" then input(put("&amp;amp;REPORTINGDATE.",$5.),yymmd.)
WARNING: Apparent symbolic reference REPORTINGDATE not resolved.
654        WHEN PROFITABILITY_FLG ne "O" then min(input(PREMIUM,anydtdte7.),input(COVERAGE,anydtdte7.)
654      ! )
655        END from work.temp;
ERROR: The informat YYMMD was not found or could not be loaded.
ERROR: Result of WHEN clause 2 is not the same data type as the preceding results.
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I want the Output value as 30JUN2003&amp;nbsp;and it should be&amp;nbsp;numeric value when &lt;CODE class=" language-sas"&gt;PROFITABILITY_FLG&lt;/CODE&gt; equals "O"&lt;/P&gt;</description>
    <pubDate>Fri, 20 Dec 2019 10:25:20 GMT</pubDate>
    <dc:creator>Babloo</dc:creator>
    <dc:date>2019-12-20T10:25:20Z</dc:date>
    <item>
      <title>Date format understanding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-format-understanding/m-p/613209#M179067</link>
      <description>&lt;P&gt;Could you please help me to resolve the error?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Value of macro variable is defined as&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let REPORTINGDATE =15886;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;649        proc sql;
650           651           select CASE
652        WHEN PROFITABILITY_FLG= "" then .
653        WHEN PROFITABILITY_FLG= "O" then input(put("&amp;amp;REPORTINGDATE.",$5.),yymmd.)
WARNING: Apparent symbolic reference REPORTINGDATE not resolved.
654        WHEN PROFITABILITY_FLG ne "O" then min(input(PREMIUM,anydtdte7.),input(COVERAGE,anydtdte7.)
654      ! )
655        END from work.temp;
ERROR: The informat YYMMD was not found or could not be loaded.
ERROR: Result of WHEN clause 2 is not the same data type as the preceding results.
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I want the Output value as 30JUN2003&amp;nbsp;and it should be&amp;nbsp;numeric value when &lt;CODE class=" language-sas"&gt;PROFITABILITY_FLG&lt;/CODE&gt; equals "O"&lt;/P&gt;</description>
      <pubDate>Fri, 20 Dec 2019 10:25:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-format-understanding/m-p/613209#M179067</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2019-12-20T10:25:20Z</dc:date>
    </item>
    <item>
      <title>Re: Date format understanding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-format-understanding/m-p/613211#M179069</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/8409"&gt;@Babloo&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you mean applying a different format to the new variable according to the flag value ?&lt;/P&gt;
&lt;P&gt;As far as I know, that's not possible, as a format is a variable attribute.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Dec 2019 10:36:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-format-understanding/m-p/613211#M179069</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2019-12-20T10:36:28Z</dc:date>
    </item>
    <item>
      <title>Re: Date format understanding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-format-understanding/m-p/613214#M179071</link>
      <description>&lt;P&gt;yes, I want to apply a Format based on the Input values. Above log message is from SAS DI Studio. However when I run the code is EG, it is working as excepted. Not sure how to make it to work in DI Studio.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input FLG $ ;
datalines;
O 
O  
P 
;
run;

%let REPORTINGDATE=15886; /*corresponding date is 20030630*/

proc sql;
create table output as select *,CASE   
WHEN FLG= "" then . 
WHEN FLG= "O" then input("&amp;amp;REPORTINGDATE.",yymmd.)
END as IR format=date9. from test;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Output:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="144" style="width: 108pt; border-collapse: collapse;" border="0" cellspacing="0" cellpadding="0"&gt;&lt;COLGROUP&gt;&lt;COL width="72" style="width: 54pt;" span="2" /&gt;&lt;/COLGROUP&gt;
&lt;TBODY&gt;
&lt;TR style="height: 15pt;"&gt;
&lt;TD width="72" height="20" style="border: 0.5pt solid windowtext; border-image: none; width: 54pt; height: 15pt; background-color: transparent;"&gt;&lt;STRONG&gt;&lt;FONT color="#000000" face="Arial" size="3"&gt;FLG&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="72" style="border-width: 0.5pt 0.5pt 0.5pt 0px; border-style: solid solid solid none; border-color: windowtext windowtext windowtext black; width: 54pt; background-color: transparent;"&gt;&lt;STRONG&gt;&lt;FONT color="#000000" face="Arial" size="3"&gt;IR&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.25pt;"&gt;
&lt;TD height="19" style="border-width: 0px 0.5pt 0.5pt; border-style: none solid solid; border-color: black windowtext windowtext; height: 14.25pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Arial" size="3"&gt;O&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: black windowtext windowtext black; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Arial" size="3"&gt;30. Jun 03&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.25pt;"&gt;
&lt;TD height="19" style="border-width: 0px 0.5pt 0.5pt; border-style: none solid solid; border-color: black windowtext windowtext; height: 14.25pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Arial" size="3"&gt;O&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD align="right" style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: black windowtext windowtext black; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Arial" size="3"&gt;30. Jun 03&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.25pt;"&gt;
&lt;TD height="19" style="border-width: 0px 0.5pt 0.5pt; border-style: none solid solid; border-color: black windowtext windowtext; height: 14.25pt; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Arial" size="3"&gt;P&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD style="border-width: 0px 0.5pt 0.5pt 0px; border-style: none solid solid none; border-color: black windowtext windowtext black; background-color: transparent;"&gt;&lt;FONT color="#000000" face="Arial" size="3"&gt;.&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Fri, 20 Dec 2019 10:46:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-format-understanding/m-p/613214#M179071</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2019-12-20T10:46:40Z</dc:date>
    </item>
    <item>
      <title>Re: Date format understanding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-format-understanding/m-p/613226#M179075</link>
      <description>&lt;PRE&gt;WARNING: Apparent symbolic reference REPORTINGDATE not resolved.&lt;/PRE&gt;
&lt;P&gt;You have not defined the macro variable REPORTINGDATE at the time it is to be used. I know you think you have assigned a value to &amp;amp;REPORTINGDATE, but SAS does not think you have done so (and you haven't shown us the portion of the code where you do this assigning) and so, SAS can't process any code involving &amp;amp;REPORTINGDATE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;WHEN PROFITABILITY_FLG= "O" then input(put("&amp;amp;REPORTINGDATE.",$5.),yymmd.)&lt;/PRE&gt;
&lt;P&gt;Assuming reporting date is properly defined, it this completely unnecessary to go through these input(put()) gyrations with a macro variable. If the macro variable has value 15886, and this is a SAS date, then you assign the value to the variable in PROC SQL and then format it. Thus the code should look like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;WHEN PROFITABILITY_FLG= "O" then &amp;amp;reportingdate&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Why? Because you can assign a value of 15886 to a numeric variable, you cannot assign a formatted value such as 19/12/30 to a numeric variable. When you assign a value of 15886, then you can assign a format to this variable.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;WHEN PROFITABILITY_FLG= "O" then input(put("&amp;amp;REPORTINGDATE.",$5.),yymmd.)
ERROR: The informat YYMMD was not found or could not be loaded.&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Can you spot the error here?&lt;/P&gt;</description>
      <pubDate>Fri, 20 Dec 2019 13:17:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-format-understanding/m-p/613226#M179075</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-12-20T13:17:26Z</dc:date>
    </item>
  </channel>
</rss>

