<?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: Datatype error while stacking files and comparing using proc import in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Datatype-error-while-stacking-files-and-comparing-using-proc/m-p/918642#M361857</link>
    <description>&lt;P&gt;If you need consistency with regards to data types and other variable attributes, then you&amp;nbsp;&lt;STRONG&gt;MUST NOT&lt;/STRONG&gt; use PROC IMPORT, which also means that you&amp;nbsp;&lt;STRONG&gt;MUST NOT&lt;/STRONG&gt; use Excel files as data source.&lt;/P&gt;
&lt;P&gt;All means that SAS provides for reading Excel files involve&amp;nbsp;&lt;EM&gt;guessing&lt;/EM&gt; and are notoriously unreliable.&lt;/P&gt;
&lt;P&gt;From where do these Excel files come?&lt;/P&gt;</description>
    <pubDate>Fri, 01 Mar 2024 19:44:04 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2024-03-01T19:44:04Z</dc:date>
    <item>
      <title>Datatype error while stacking files and comparing using proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datatype-error-while-stacking-files-and-comparing-using-proc/m-p/918641#M361856</link>
      <description>&lt;P&gt;Headsup ! I am a beginner in sas. Appreciate your time, kindness and help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a master dataset and three sub datasets ,with various columns puled from Oracle database. The code works till I pull the data, merge. I run this everyday, the output is an excel file with acct_num, acct_id and other columns. the logic looks back last 7 days and fetches the result.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Now, the tricky part is I am comparing the today's file to last 7 days and remove duplicates from today's report.( My previous post was to seek help on defining &amp;amp;yesterday, and with the help I created &amp;amp;previous_day 1 to 7 , stacked)&lt;/LI&gt;&lt;LI&gt;After the comparison runs and when I pull the final data, I have this datatype error that seems to be difficult to resolve. I used APPEND, APPEND with FORCE, I also tried creating TEST dataset so my first previous_day1 report will look at test and avoid any data type error IF the previous report has ANY NULL data.&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;DIV&gt;253 data myora.final_result2;&lt;BR /&gt;254 /*format open_dt 10. close_dt 10. merch_num 12. DOB $10.;*/&lt;BR /&gt;255 merge myora.final_result (in=a) Previous_report1(in=b) Previous_report2 (in=c)&lt;BR /&gt;255! Previous_report3 (in=d) Previous_report4 (in=e) Previous_report5 (in=f) Previous_report6&lt;BR /&gt;255! (in=g) Previous_report7(in=h);&lt;BR /&gt;ERROR: Variable OPEN_DT has been defined as both character and numeric.&lt;BR /&gt;ERROR: Variable CLOSE_DT has been defined as both character and numeric.&lt;BR /&gt;ERROR: Variable MERCH_NUM has been defined as both character and numeric.&lt;BR /&gt;ERROR: Variable DOB has been defined as both character and numeric.&lt;BR /&gt;ERROR: Variable ACCT_NUM has been defined as both character and numeric&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;%let current_day = %sysfunc(today());&lt;/DIV&gt;&lt;DIV&gt;%let weekday = %sysfunc(weekday(&amp;amp;current_day.));&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;%if &amp;amp;weekday. = 2 %then %do;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; /* If it's Monday, fetch friday */&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; %let previous_day&amp;nbsp; = %sysfunc(intnx(day, &amp;amp;current_day., -3), date9.);&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;%let previous_day2 = %sysfunc(intnx(day, &amp;amp;current_day., -4), date9.);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;%let previous_day3 = %sysfunc(intnx(day, &amp;amp;current_day., -5), date9.);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;%let previous_day4 = %sysfunc(intnx(day, &amp;amp;current_day., -6), date9.);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; %let previous_day5 = %sysfunc(intnx(day, &amp;amp;current_day., -7), date9.);&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;%let previous_day6 = %sysfunc(intnx(day, &amp;amp;current_day., -8), date9.);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;%let previous_day7 = %sysfunc(intnx(day, &amp;amp;current_day., -9), date9.);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;%end;&lt;/DIV&gt;&lt;DIV&gt;%else %do;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; /* For the rest of the week, refer to yesterday */&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; %let previous_day&amp;nbsp; = %sysfunc(intnx(day, &amp;amp;current_day., -1), date9.);&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;%let previous_day2 = %sysfunc(intnx(day, &amp;amp;current_day., -2), date9.);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;%let previous_day3 = %sysfunc(intnx(day, &amp;amp;current_day., -3), date9.);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;%let previous_day4 = %sysfunc(intnx(day, &amp;amp;current_day., -4), date9.);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; %let previous_day5 = %sysfunc(intnx(day, &amp;amp;current_day., -5), date9.);&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;%let previous_day6 = %sysfunc(intnx(day, &amp;amp;current_day., -6), date9.);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;%let previous_day7 = %sysfunc(intnx(day, &amp;amp;current_day., -7), date9.);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;%end;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;%put &amp;amp;previous_day.;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;PROC IMPORT&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; DATAFILE = "filepath\Output\filename&amp;amp;previous_day..xlsx"&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; OUT = Previous_report1&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; DBMS = EXCEL REPLACE;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; RANGE = 'possible_accts$';&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; MIXED = YES;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; SCANTEXT = YES;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; USEDATE = YES;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; SCANTIME = YES;&lt;/DIV&gt;&lt;DIV&gt;RUN;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;/*proc print data = Previous_report1;run;*/&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;PROC IMPORT&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; DATAFILE = "filepath\Output\filename&amp;amp;previous_day2..xlsx"&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; OUT = Previous_report2&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; DBMS = EXCEL REPLACE;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; RANGE = 'possible_accts$';&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; MIXED = YES;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; SCANTEXT = YES;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; USEDATE = YES;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; SCANTIME = YES;&lt;/DIV&gt;&lt;DIV&gt;RUN;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;/*proc print data = Previous_report2;run;*/&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;PROC IMPORT&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; DATAFILE = "filepath\Output\filename&amp;amp;previous_day3..xlsx"&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; OUT = Previous_report3&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; DBMS = EXCEL REPLACE;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; RANGE = 'possible_accts$';&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; MIXED = YES;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; SCANTEXT = YES;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; USEDATE = YES;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; SCANTIME = YES;&lt;/DIV&gt;&lt;DIV&gt;RUN;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;PROC IMPORT&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; DATAFILE = "filepath\Output\filename&amp;amp;previous_day4..xlsx"&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; OUT = Previous_report4&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; DBMS = EXCEL REPLACE;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; RANGE = 'possible_accts$';&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; MIXED = YES;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; SCANTEXT = YES;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; USEDATE = YES;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; SCANTIME = YES;&lt;/DIV&gt;&lt;DIV&gt;RUN;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;PROC IMPORT&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; DATAFILE = "filepath\Output\filename&amp;amp;previous_day5..xlsx"&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; OUT = Previous_report5&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; DBMS = EXCEL REPLACE;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; RANGE = 'possible_accts$';&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; MIXED = YES;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; SCANTEXT = YES;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; USEDATE = YES;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; SCANTIME = YES;&lt;/DIV&gt;&lt;DIV&gt;RUN;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;PROC IMPORT&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; DATAFILE = "filepath\Output\filename&amp;amp;previous_day6..xlsx"&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; OUT = Previous_report6&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; DBMS = EXCEL REPLACE;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; RANGE = 'possible_accts$';&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; MIXED = YES;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; SCANTEXT = YES;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; USEDATE = YES;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; SCANTIME = YES;&lt;/DIV&gt;&lt;DIV&gt;RUN;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;PROC IMPORT&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; DATAFILE = "filepath\Output\filename&amp;amp;previous_day7..xlsx"&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; OUT = Previous_report7&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; DBMS = EXCEL REPLACE;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; RANGE = 'possible_accts$';&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; MIXED = YES;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; SCANTEXT = YES;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; USEDATE = YES;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; SCANTIME = YES;&lt;/DIV&gt;&lt;DIV&gt;RUN;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;proc delete data=test;run;&lt;/DIV&gt;&lt;DIV&gt;data test;&lt;/DIV&gt;&lt;DIV&gt;/* Define variable lengths */&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; format acct_num 16. acct_id 8. tran_dt 12. open_dt $10. close_dt 10. cheque_pymt 30. merch_num 12. postal_cd $6. count_cash_adv 4. total_cash_adv 9. name $15. DOB $10. email $24. tel_home 10. addr_ln1 $17.;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;rsubmit;&lt;/DIV&gt;&lt;DIV&gt;proc upload data=test;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;DIV&gt;proc sort data=test;&lt;/DIV&gt;&lt;DIV&gt;by acct_id;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;proc upload data=Previous_report1 ;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;DIV&gt;proc sort data=Previous_report1;&lt;/DIV&gt;&lt;DIV&gt;by acct_id;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;proc upload data=Previous_report2 ;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;DIV&gt;proc sort data=Previous_report2;&lt;/DIV&gt;&lt;DIV&gt;by acct_id;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;DIV&gt;proc upload data=Previous_report3 ;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;DIV&gt;proc sort data=Previous_report3;&lt;/DIV&gt;&lt;DIV&gt;by acct_id;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;DIV&gt;proc upload data=Previous_report4 ;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;DIV&gt;proc sort data=Previous_report4;&lt;/DIV&gt;&lt;DIV&gt;by acct_id;&lt;/DIV&gt;&lt;DIV&gt;run;proc upload data=Previous_report5 ;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;DIV&gt;proc sort data=Previous_report5;&lt;/DIV&gt;&lt;DIV&gt;by acct_id;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;DIV&gt;proc upload data=Previous_report6 ;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;DIV&gt;proc sort data=Previous_report6;&lt;/DIV&gt;&lt;DIV&gt;by acct_id;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;DIV&gt;proc upload data=Previous_report7 ;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;DIV&gt;proc sort data=Previous_report7;&lt;/DIV&gt;&lt;DIV&gt;by acct_id;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;DIV&gt;endrsubmit;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;proc append base=test data=Previous_report1 FORCE;run;&lt;/DIV&gt;&lt;DIV&gt;/* try to run it without FORCE and then with force */&lt;/DIV&gt;&lt;DIV&gt;proc append base=test data=Previous_report2 FORCE;run;&lt;/DIV&gt;&lt;DIV&gt;proc append base=test data=Previous_report3 FORCE;run;&lt;/DIV&gt;&lt;DIV&gt;proc append base=test data=Previous_report4 FORCE;run;&lt;/DIV&gt;&lt;DIV&gt;proc append base=test data=Previous_report5 FORCE;run;&lt;/DIV&gt;&lt;DIV&gt;proc append base=test data=Previous_report6 FORCE;run;&lt;/DIV&gt;&lt;DIV&gt;proc append base=test data=Previous_report7 FORCE;run;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;rsubmit;&lt;/DIV&gt;&lt;DIV&gt;proc delete data= myora.final_result2;run;&lt;/DIV&gt;&lt;DIV&gt;data myora.final_result2;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;merge myora.final_result (in=a) Previous_report1(in=b) Previous_report2 (in=c) Previous_report3&amp;nbsp; (in=d)&amp;nbsp; Previous_report4 (in=e) Previous_report5 (in=f) Previous_report6 (in=g) Previous_report7(in=h);&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;by acct_id ;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;if a and not b and not c and not d and not e and not f and not g and not h;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;run;&lt;/DIV&gt;&lt;DIV&gt;endrsubmit;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;rsubmit; /*table for result */&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;proc sql;&lt;/DIV&gt;&lt;DIV&gt;connect to oracle(&amp;amp;ora_str.);&lt;/DIV&gt;&lt;DIV&gt;create table final as&lt;/DIV&gt;&lt;DIV&gt;select * from connection to oracle(&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;select ACCT_NUM,ACCT_ID, CHEQUE_PYMT,NAME, DOB, EMAIL, TEL_HOME, ADDR_LN1&lt;/DIV&gt;&lt;DIV&gt;from&amp;nbsp; final_result2 where CHEQUE_PYMT &amp;gt;= '1000.00'&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;);&lt;/DIV&gt;&lt;DIV&gt;disconnect from oracle;&lt;/DIV&gt;&lt;DIV&gt;quit;&lt;/DIV&gt;&lt;DIV&gt;endrsubmit;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;rsubmit;&lt;/DIV&gt;&lt;DIV&gt;proc download data=final;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;DIV&gt;endrsubmit;&lt;/DIV&gt;</description>
      <pubDate>Fri, 01 Mar 2024 19:23:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datatype-error-while-stacking-files-and-comparing-using-proc/m-p/918641#M361856</guid>
      <dc:creator>User_2024</dc:creator>
      <dc:date>2024-03-01T19:23:46Z</dc:date>
    </item>
    <item>
      <title>Re: Datatype error while stacking files and comparing using proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datatype-error-while-stacking-files-and-comparing-using-proc/m-p/918642#M361857</link>
      <description>&lt;P&gt;If you need consistency with regards to data types and other variable attributes, then you&amp;nbsp;&lt;STRONG&gt;MUST NOT&lt;/STRONG&gt; use PROC IMPORT, which also means that you&amp;nbsp;&lt;STRONG&gt;MUST NOT&lt;/STRONG&gt; use Excel files as data source.&lt;/P&gt;
&lt;P&gt;All means that SAS provides for reading Excel files involve&amp;nbsp;&lt;EM&gt;guessing&lt;/EM&gt; and are notoriously unreliable.&lt;/P&gt;
&lt;P&gt;From where do these Excel files come?&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2024 19:44:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datatype-error-while-stacking-files-and-comparing-using-proc/m-p/918642#M361857</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2024-03-01T19:44:04Z</dc:date>
    </item>
    <item>
      <title>Re: Datatype error while stacking files and comparing using proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datatype-error-while-stacking-files-and-comparing-using-proc/m-p/918645#M361858</link>
      <description>&lt;P&gt;Ah... ok. So, I generate the output using EXCEL files.&amp;nbsp; and this has to come out everyday for reviewing purposes with acct_num and other demographic info. Ideally my problem is todays_report should not have ANY entries /duplicates from yesterdays or day before. the code works if I compare todays report to yesterdays and THEN PRINT todays BUT if there are Zero records for today then it pulls data from day before yesterday's which is such a pain now.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2024 19:52:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datatype-error-while-stacking-files-and-comparing-using-proc/m-p/918645#M361858</guid>
      <dc:creator>User_2024</dc:creator>
      <dc:date>2024-03-01T19:52:00Z</dc:date>
    </item>
    <item>
      <title>Re: Datatype error while stacking files and comparing using proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datatype-error-while-stacking-files-and-comparing-using-proc/m-p/918647#M361859</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/464126"&gt;@User_2024&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Ah... ok. So, I generate the output using EXCEL files.&amp;nbsp; and this has to come out everyday for reviewing purposes with acct_num and other demographic info. Ideally my problem is todays_report should not have ANY entries /duplicates from yesterdays or day before. the code works if I compare todays report to yesterdays and THEN PRINT todays BUT if there are Zero records for today then it pulls data from day before yesterday's which is such a pain now.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;IF you are generating the Excel files as output are you doing it from SAS? If so, then the place to start would be the data sets used to create that Excel output, not rereading output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;FWIW in a typical week I read anywhere from 10 to 50 files that start out as XLSX. Because of the headaches involved with that I save them to CSV and then can use a data step to read the files into consistent variables by type, length and name.(Until the idiots providing the source change the column order, then I need to change the order of the Input statement I use.)&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2024 20:08:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datatype-error-while-stacking-files-and-comparing-using-proc/m-p/918647#M361859</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-03-01T20:08:49Z</dc:date>
    </item>
    <item>
      <title>Re: Datatype error while stacking files and comparing using proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datatype-error-while-stacking-files-and-comparing-using-proc/m-p/918648#M361860</link>
      <description>ohh. thats a great point, I am just starting to create reports using SAS. And yes, you are right, i use SAS to create the XLSX report. can you throw me a sample how I can convert this to CSV now ? and all my previous 7 days files are also in XLSX. How to fix them now ? this is how I do it. any insights are sincerely appreciated .&lt;BR /&gt;&lt;BR /&gt;proc export&lt;BR /&gt;data=final outfile="filepath\Output\filename&amp;amp;today..xlsx"&lt;BR /&gt;dbms=xlsx replace;&lt;BR /&gt;sheet="data_for_review";&lt;BR /&gt;run;</description>
      <pubDate>Fri, 01 Mar 2024 20:17:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datatype-error-while-stacking-files-and-comparing-using-proc/m-p/918648#M361860</guid>
      <dc:creator>User_2024</dc:creator>
      <dc:date>2024-03-01T20:17:35Z</dc:date>
    </item>
    <item>
      <title>Re: Datatype error while stacking files and comparing using proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datatype-error-while-stacking-files-and-comparing-using-proc/m-p/918651#M361862</link>
      <description>&lt;P&gt;Keep the data in SAS. Create those Excel reports for reviewing, but keep the underlying data as SAS datasets for further processing.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2024 20:38:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datatype-error-while-stacking-files-and-comparing-using-proc/m-p/918651#M361862</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2024-03-01T20:38:42Z</dc:date>
    </item>
    <item>
      <title>Re: Datatype error while stacking files and comparing using proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datatype-error-while-stacking-files-and-comparing-using-proc/m-p/918652#M361863</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/464126"&gt;@User_2024&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;ohh. thats a great point, I am just starting to create reports using SAS. And yes, you are right, i use SAS to create the XLSX report. can you throw me a sample how I can convert this to CSV now ? and all my previous 7 days files are also in XLSX. How to fix them now ? this is how I do it. any insights are sincerely appreciated .&lt;BR /&gt;&lt;BR /&gt;proc export&lt;BR /&gt;data=final outfile="filepath\Output\filename&amp;amp;today..xlsx"&lt;BR /&gt;dbms=xlsx replace;&lt;BR /&gt;sheet="data_for_review";&lt;BR /&gt;run;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I would create a permanent library for the data related to this project. Then as you make a "final" data set either append it to a long-term set in that library&amp;nbsp; (best if the contents don't change often) or, and I know this is unpopular for many reasons, make a copy in that permanent library with the date in the name such as Final_20240301. This may be better if the contents do change, meaning the number of variables, the names of the variables and metadata.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then combine the data sets as needed (if the append approach isn't feasible and may not be with a history of Proc Import...)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2024 20:46:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datatype-error-while-stacking-files-and-comparing-using-proc/m-p/918652#M361863</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-03-01T20:46:15Z</dc:date>
    </item>
    <item>
      <title>Re: Datatype error while stacking files and comparing using proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datatype-error-while-stacking-files-and-comparing-using-proc/m-p/918707#M361893</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/464126"&gt;@User_2024&lt;/a&gt;&amp;nbsp;Looking at the code you share I feel it might be worth to take a step back and look at your whole process and potentially revamp it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;"I have a master dataset and three sub datasets ,with various columns puled from Oracle database.&amp;nbsp;"&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;1. Is all your data in Oracle or only some additional information that you use to enrich your master dataset?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;2. Where is your master dataset stored?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"&lt;EM&gt;Now, the tricky part is I am comparing the today's file to last 7 days and remove duplicates from today's report.&lt;/EM&gt;"&lt;/P&gt;
&lt;P&gt;3. What constitutes a "duplicate" and why do you get them in first place?&lt;/P&gt;
&lt;P&gt;4. Are there updates to your source data between your daily queries (like a change to open_dt)?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;6. What's the purpose of these rsubmit in your code. Why do you need them?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And as others already stated:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do not use Excel as a data source. Easiest would be to store the daily SAS table permanently that you use to create the Excel and then use these SAS tables the next day.&lt;/P&gt;
&lt;P&gt;You could either create daily tables with a date portion in the table name or append daily data to a single table with a date column.&lt;/P&gt;</description>
      <pubDate>Sun, 03 Mar 2024 01:30:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datatype-error-while-stacking-files-and-comparing-using-proc/m-p/918707#M361893</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-03-03T01:30:40Z</dc:date>
    </item>
    <item>
      <title>Re: Datatype error while stacking files and comparing using proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datatype-error-while-stacking-files-and-comparing-using-proc/m-p/918821#M361921</link>
      <description>1. Is all your data in Oracle or only some additional information that you use to enrich your master dataset? - All of my data are from Oracle sql.&lt;BR /&gt;&lt;BR /&gt;2. Where is your master dataset stored? - its in myora. and not in WORK.&lt;BR /&gt;&lt;BR /&gt;6. What's the purpose of these rsubmit in your code. Why do you need them?- I always use them for ease of execution. Since am a beginnner in sas, I am open for suggestions and ideas, this will be my first ever report creation in SAS. Appreciate your insights and time!</description>
      <pubDate>Mon, 04 Mar 2024 13:13:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datatype-error-while-stacking-files-and-comparing-using-proc/m-p/918821#M361921</guid>
      <dc:creator>User_2024</dc:creator>
      <dc:date>2024-03-04T13:13:06Z</dc:date>
    </item>
    <item>
      <title>Re: Datatype error while stacking files and comparing using proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datatype-error-while-stacking-files-and-comparing-using-proc/m-p/918822#M361922</link>
      <description>Thanks, could you point me for an example pls?</description>
      <pubDate>Mon, 04 Mar 2024 13:13:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datatype-error-while-stacking-files-and-comparing-using-proc/m-p/918822#M361922</guid>
      <dc:creator>User_2024</dc:creator>
      <dc:date>2024-03-04T13:13:39Z</dc:date>
    </item>
    <item>
      <title>Re: Datatype error while stacking files and comparing using proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datatype-error-while-stacking-files-and-comparing-using-proc/m-p/918823#M361923</link>
      <description>Thank you, any sample syntax or code pls ? Appreciate your time.</description>
      <pubDate>Mon, 04 Mar 2024 13:14:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datatype-error-while-stacking-files-and-comparing-using-proc/m-p/918823#M361923</guid>
      <dc:creator>User_2024</dc:creator>
      <dc:date>2024-03-04T13:14:27Z</dc:date>
    </item>
    <item>
      <title>Re: Datatype error while stacking files and comparing using proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datatype-error-while-stacking-files-and-comparing-using-proc/m-p/918824#M361924</link>
      <description>3. What constitutes a "duplicate" and why do you get them in first place? - i run this report on weekdays and i use the date constraint to look at last 7 days of data TRANSACTION_DT &amp;lt; TRUNC(SYSDATE) -7 so for example when the report runs today, it picks up records from last 7 days and has duplicates in it, so I did a proc import to compare yesterdays to today to remove dupes, which works for one day, BUT if today;s report has NO DATA in it, it goes and picks up day before yesterdays data as output. So to avoid that I started stacking last 7 days of output files, sorted by acct_id and compared with today's , removed duplicates. but at this point, its not working because of the data type error.&lt;BR /&gt;&lt;BR /&gt;4. Are there updates to your source data between your daily queries (like a change to open_dt)?- no, open_dt is the date when the account was opened so no change in it, the only change is at the Transaction_dt as the real time transaction happens,</description>
      <pubDate>Mon, 04 Mar 2024 13:26:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datatype-error-while-stacking-files-and-comparing-using-proc/m-p/918824#M361924</guid>
      <dc:creator>User_2024</dc:creator>
      <dc:date>2024-03-04T13:26:24Z</dc:date>
    </item>
    <item>
      <title>Re: Datatype error while stacking files and comparing using proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datatype-error-while-stacking-files-and-comparing-using-proc/m-p/918910#M361954</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/464126"&gt;@User_2024&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"and i use the date constraint to look at last 7 days of data TRANSACTION_DT &amp;lt; TRUNC(SYSDATE) -7"&lt;BR /&gt;Above selection would return all rows with a transaction date OLDER than 7 days.&lt;/P&gt;
&lt;P&gt;To select the past 7 days (without the current day where you won't have all transactions):&lt;/P&gt;
&lt;PRE&gt;TRANSACTION_DT between TRUNC(SYSDATE) -7 and TRUNC(SYSDATE) -1&lt;/PRE&gt;
&lt;P&gt;Assuming you don't have duplicate transactions in your source, your definition of duplicates doesn't make much sense to me.&lt;BR /&gt;It feels this is more an issue with your selection logic and not with your data.&lt;BR /&gt;If you just want to select yesterday's transactions change your selection to:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;TRANSACTION_DT = TRUNC(SYSDATE) -1&lt;/PRE&gt;
&lt;P&gt;As I understand it your report is at account level and not at transaction level so at some point you're aggregating the data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why do you need transaction level data at all? Like: Is this some summary of transactions per account over the last 7 days and you only want to include accounts that had a change yesterday? If so then it wouldn't be hard to identify all accounts with a change yesterday directly on the Oracle side and only create account level aggregated rows moved to SAS that meet this condition.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You just need to describe a bit more in detail what you have and what your end result needs to be.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2024 23:54:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datatype-error-while-stacking-files-and-comparing-using-proc/m-p/918910#M361954</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-03-04T23:54:18Z</dc:date>
    </item>
    <item>
      <title>Re: Datatype error while stacking files and comparing using proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datatype-error-while-stacking-files-and-comparing-using-proc/m-p/919178#M362058</link>
      <description>&lt;P&gt;Thank you for suggesting. I am trying to find payments made in last 7 days, and I need to run this daily, When I do this I stumbled into duplicates because data from say for example from Mar3 shows up in MAr4 when I run it, and it also shows up when I run on Mar5. And I gotta look at last 7 days because there could be different payment type like cheques.&amp;nbsp;&lt;/P&gt;&lt;P&gt;To resolve it, I imported yesterday's output file, compared to today's, removed duplicates, which worked fine.&amp;nbsp;&lt;/P&gt;&lt;P&gt;But, when I did that for multiple days, I faced datatype error and that when I approached the community. Hope, this helps.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Issues were on defining today, yesterday macros that got fixed from help here. And finally resolved the datatype error by keeping just the index variable while stacking.&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc upload data=Previous_report1 (keep=acct_id);&lt;BR /&gt;run;&lt;BR /&gt;proc sort data=Previous_report1;&lt;BR /&gt;by acct_id;&lt;BR /&gt;run;&lt;BR /&gt;proc upload data=Previous_report2 (keep=acct_id);&lt;BR /&gt;run;&lt;BR /&gt;proc sort data=Previous_report2;&lt;BR /&gt;by acct_id;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Mar 2024 18:16:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datatype-error-while-stacking-files-and-comparing-using-proc/m-p/919178#M362058</guid>
      <dc:creator>User_2024</dc:creator>
      <dc:date>2024-03-06T18:16:45Z</dc:date>
    </item>
    <item>
      <title>Re: Datatype error while stacking files and comparing using proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datatype-error-while-stacking-files-and-comparing-using-proc/m-p/919214#M362069</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/464126"&gt;@User_2024&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you for suggesting. I am trying to find payments made in last 7 days, and I need to run this daily, When I do this I stumbled into duplicates because data from say for example from Mar3 shows up in MAr4 when I run it, and it also shows up when I run on Mar5. And I gotta look at last 7 days because there could be different payment type like cheques.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To resolve it, I imported yesterday's output file, compared to today's, removed duplicates, which worked fine.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But, when I did that for multiple days, I faced datatype error and that when I approached the community. Hope, this helps.&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes, of course, if you run daily but select the last 7 days of transactions then you will select the same transaction on multiple days.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"&lt;EM&gt;And I gotta look at last 7 days because there could be different payment type like cheques.&lt;/EM&gt;"&lt;/P&gt;
&lt;P&gt;And you want to report (select) this check payment now for 7 days or only once?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I still believe that ideally you would write logic that does the desired selection directly on the database instead of reading and processing some .csv or Excel for post processing that you created via runs on past days. Just an opinion.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Mar 2024 23:29:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datatype-error-while-stacking-files-and-comparing-using-proc/m-p/919214#M362069</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-03-06T23:29:46Z</dc:date>
    </item>
    <item>
      <title>Re: Datatype error while stacking files and comparing using proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datatype-error-while-stacking-files-and-comparing-using-proc/m-p/919611#M362210</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/464126"&gt;@User_2024&lt;/a&gt;&amp;nbsp;I felt I should share your reply to our private message here. I hope you don't mind.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Thank you for the suggestion, I will keep the discussions in public for all my posts from now on. But, let me answer for the questions here,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Is my understanding correct that in your master table you've got transactional data where in a single row you've got the customer_id, transaction type and transaction date? -&amp;nbsp;&lt;FONT face="book antiqua,palatino"&gt;&lt;STRONG&gt;Yes, your understanding is correct.&lt;/STRONG&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Let's say you're running your program on a Wednesday: Do I understand this right that the only customers you'd want to report on are the ones that had a type1 transaction on Tuesday (your most current data) and never had such a type 1 transaction on any earlier date? ---&amp;nbsp;&lt;STRONG&gt;&lt;FONT face="book antiqua,palatino"&gt;That would be correct, sometimes the payment table gets updated later in the day which "may" miss that days data if i run the job in the morning. That is why I always look back for last 5 weekdays.&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If you run your program on a Monday then you would select the previous Friday-Sunday because the last report you run on Friday only included data up-to Thursday. -&lt;FONT face="book antiqua,palatino"&gt;&lt;STRONG&gt;&amp;nbsp;this is accurate.&amp;nbsp; And, I will run only on weekdays, but if we have a public holiday on a weekday, I think I have to think about how other similar jobs are set up among my team mates.&amp;nbsp;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Sat, 09 Mar 2024 02:31:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datatype-error-while-stacking-files-and-comparing-using-proc/m-p/919611#M362210</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-03-09T02:31:51Z</dc:date>
    </item>
    <item>
      <title>Re: Datatype error while stacking files and comparing using proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datatype-error-while-stacking-files-and-comparing-using-proc/m-p/919612#M362211</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/464126"&gt;@User_2024&lt;/a&gt;&amp;nbsp;Based on what you've told me below some "template" sample code to show how logic could work only using your one main table in Oracle.&lt;/P&gt;
&lt;P&gt;I would only switch to something more "complicated" for performance reasons - like maintaining a separate table with customer ids selected in earlier runs instead of working this out every single time like in below query.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options dlcreatedir;
libname ora  "%sysfunc(pathname(work))/oracle";
libname ctrl "%sysfunc(pathname(work))/perm_storage";

/* master source table with all transactions */
data ora.master;
  infile datalines truncover dlm=',';
  input trans_id acct_id$ cust_id$ trans_type trans_dttm:anydtdtm.;
  format trans_dttm datetime20.;
  datalines;
1,a,x,1,01jan2024
2,a,x,2,01feb2024
3,b,x,1,01mar2024
2,a,x,2,02mar2024
2,b,x,2,02mar2024
;

/* control table to store max transaction date selected in a previous run */
/* - needs to be a permanent table    
   - create table if it doesn't exist 
*/
%if not %sysfunc(exist(ctrl.last_selected)) %then
  %do;
    data ctrl.last_selected;
      attrib run_dttm max_trans_dttm format=datetime20.;
      stop;
    run;
  %end;

/* &amp;amp;prev_max_trans_dttm: max transaction date already selected in a previous run */
proc sql noprint;
  select coalesce(max(max_trans_dttm),0) format=datetime20. into :prev_max_trans_dttm trimmed
  from ctrl.last_selected
  ;
quit;


/* create data for reporting:
   - only include transactions of type 1
   - only select transaction dates &amp;gt; &amp;amp;prev_max_trans_dttm
   - exclude transactions that already had been selected in earlier runs
      = transactions for customers that already had a type 1 transaction at or before &amp;amp;prev_max_trans_dttm
*/
proc sql;
  create table work.report_source as
    select cust_id, trans_type, trans_dttm
      from
        (
          select cust_id, trans_type, trans_dttm
            from ora.master
              where trans_dttm&amp;gt;"&amp;amp;prev_max_trans_dttm"dt and trans_type=1
                group by cust_id
                  having max(trans_dttm)=trans_dttm
        )
          where not exists
            (
              select distinct cust_id
                from ora.master
                  where trans_dttm&amp;lt;="&amp;amp;prev_max_trans_dttm"dt and trans_type=1
            )
  ;
quit;

/* add most current max transaction date selected to control table */
proc sql;
  insert into ctrl.last_selected
    set run_dttm=datetime(), max_trans_dttm=max("&amp;amp;prev_max_trans_dttm"dt,(select max(trans_dttm) from report_source))
  ;
quit;


/* and here just some "template" to give you an idea how to deal with a zero row result */
data _null_;
  call symputx('nobs',nobs);
  stop;
  set work.report_source nobs=nobs;
run;
%put &amp;amp;=nobs;

%if &amp;amp;nobs=0 %then
  %do;
    data _null_;
      file print;
      put "no rows selected";
    run;
  %end;
%else
  %do;
    proc print data=work.report_source;
    run;
  %end;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 09 Mar 2024 02:36:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datatype-error-while-stacking-files-and-comparing-using-proc/m-p/919612#M362211</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-03-09T02:36:55Z</dc:date>
    </item>
    <item>
      <title>Re: Datatype error while stacking files and comparing using proc import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datatype-error-while-stacking-files-and-comparing-using-proc/m-p/919745#M362279</link>
      <description>Thank you for the suggestion, I will give it a try and post here on the updates.</description>
      <pubDate>Mon, 11 Mar 2024 11:42:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datatype-error-while-stacking-files-and-comparing-using-proc/m-p/919745#M362279</guid>
      <dc:creator>User_2024</dc:creator>
      <dc:date>2024-03-11T11:42:38Z</dc:date>
    </item>
  </channel>
</rss>

