<?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: Reading in csv file with date using infile and merging 2 files with different encoding in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reading-in-csv-file-with-date-using-infile-and-merging-2-files/m-p/716225#M221311</link>
    <description>&lt;P&gt;It depends on the actual characters in the file.&amp;nbsp; If the file is using WLATIN2 and all of the characters that actually appear in the file can be mapped into your current SAS sessions encoding (let's assume that it is using WLATIN1) then you will have no problems. But as soon as one of the input text files has something that is not one of the 256 possible characters supported by WLATIN1 then you will get a null value.&amp;nbsp; Now it the other file you are matching has the same character (prehaps represented in a different encoding) then it will also be mapped to the same strange thing.&amp;nbsp; So the strings will match, but you will get some false positive matches where two string are different in just one character but neither character from the two sources can map into your current encoding.&lt;/P&gt;</description>
    <pubDate>Tue, 02 Feb 2021 21:10:45 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2021-02-02T21:10:45Z</dc:date>
    <item>
      <title>Reading in csv file with date using infile and merging 2 files with different encoding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-in-csv-file-with-date-using-infile-and-merging-2-files/m-p/715397#M220962</link>
      <description>&lt;P&gt;Hi Experts,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a 2-part question and could use your help in reading in reading in another csv file. This time my trouble is reading in the date variable in with the proper formatting while using 'infile', instead of 'proc import', because of the Polish characters.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The csv file that I need to read in has 3 variables. The dates are shown as mm/dd/yyyy (eg. 01/28/2021) but as you can see below, all the dates are missing.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RLC07_0-1611942416674.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/54113i71F0C482A31FF153/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RLC07_0-1611942416674.png" alt="RLC07_0-1611942416674.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let path=C:\Users\SAS\Poland;&lt;BR /&gt;%let fname=Poland_cases.csv;&lt;BR /&gt;options DATESTYLE=mdy;&lt;BR /&gt;data master2;&lt;BR /&gt;length loc_name $20.;&lt;BR /&gt;format date mmddyy10.;&lt;BR /&gt;infile "&amp;amp;path\&amp;amp;fname" encoding='utf-8' dsd firstobs=2 dlm=',';&lt;BR /&gt;input loc_name $ infected&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/145066"&gt;@10&lt;/a&gt; date anydtdte12.;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For this file, I have to use encoding ='utf-8' or instead of encoding ='wlatin2' or else the Polish characters wouldn't read in properly. For reading in the date, how should I change my code? I've tried a few different things already.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And the second part of my question is, will it be problematic for me to merge this file (encoding = 'utf-8') with another weekly file that was created using the daily raw data files that were read in using encoding='wlatin2'? Thanks very much!&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jan 2021 17:56:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-in-csv-file-with-date-using-infile-and-merging-2-files/m-p/715397#M220962</guid>
      <dc:creator>RLC07</dc:creator>
      <dc:date>2021-01-29T17:56:53Z</dc:date>
    </item>
    <item>
      <title>Re: Reading in csv file with date using infile and merging 2 files with different encoding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-in-csv-file-with-date-using-infile-and-merging-2-files/m-p/715408#M220967</link>
      <description>&lt;P&gt;Please post a few lines of the file by copy/pasting into a window opened with the &amp;lt;/&amp;gt; button. Open the file with a text editor (not with Excel!) to do this.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jan 2021 18:20:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-in-csv-file-with-date-using-infile-and-merging-2-files/m-p/715408#M220967</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-01-29T18:20:32Z</dc:date>
    </item>
    <item>
      <title>Re: Reading in csv file with date using infile and merging 2 files with different encoding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-in-csv-file-with-date-using-infile-and-merging-2-files/m-p/715416#M220969</link>
      <description>&lt;PRE&gt;loc_name,infected,date
Dolnośląskie,1035,11/24/2020
Dolnośląskie,825,11/25/2020
Dolnośląskie,1112,11/26/2020
Dolnośląskie,1318,11/27/2020&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jan 2021 18:48:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-in-csv-file-with-date-using-infile-and-merging-2-files/m-p/715416#M220969</guid>
      <dc:creator>RLC07</dc:creator>
      <dc:date>2021-01-29T18:48:34Z</dc:date>
    </item>
    <item>
      <title>Re: Reading in csv file with date using infile and merging 2 files with different encoding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-in-csv-file-with-date-using-infile-and-merging-2-files/m-p/715424#M220971</link>
      <description>&lt;P&gt;For the read part, this should do it:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let path=C:\Users\SAS\Poland;
%let fname=Poland_cases.csv;

data master2;
length loc_name $20.;
format date mmddyy10.;
infile "&amp;amp;path\&amp;amp;fname" encoding='utf-8' dsd firstobs=2 dlm=',';
input
  loc_name
  infected
  date :mmddyy10.
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;For the merge, get to know your data better. For instance, display the loc_name with a $hex format (length double that of the variable), so you can see the real content, and if you need to do a translation.&lt;/P&gt;
&lt;P&gt;Also do a search for "sas convert character from latin to utf", you will find lots of helpful information.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jan 2021 19:29:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-in-csv-file-with-date-using-infile-and-merging-2-files/m-p/715424#M220971</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-01-29T19:29:47Z</dc:date>
    </item>
    <item>
      <title>Re: Reading in csv file with date using infile and merging 2 files with different encoding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-in-csv-file-with-date-using-infile-and-merging-2-files/m-p/715425#M220972</link>
      <description>&lt;P&gt;You do not want to use pointer movement controls ( the&amp;nbsp;@ in your code) or fixed format mode with a delimited file.&amp;nbsp; Just let the INPUT statement parse the line based on the delimiter.&amp;nbsp; Use the : (colon) modifier in front of any in-line informats included in your INPUT statement so that values are read in list mode.&lt;/P&gt;
&lt;P&gt;Also&amp;nbsp;&lt;SPAN style="font-family: inherit;"&gt;I wouldn't use the ANYDTDTE informat, it will create different dates for the some input string based on the LOCALE setting. Better to use the informat that actually matches the order that month , day and year fields are expected to appear in the data. Plus if you use year month day order when displaying the dates then you won't confuse half your audience when the DAY number is 12 or less.&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  infile cards dsd truncover ;
  input loc_name :$20. infected date :mmddyy.;
  format date yymmdd10.;
cards;
Dolnośląskie,1035,11/24/2020
Dolnośląskie,825,11/25/2020
Dolnośląskie,1112,11/26/2020
Dolnośląskie,1318,11/27/2020
;

proc print;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results:&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 285px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/54120i488B1D8176858985/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jan 2021 19:30:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-in-csv-file-with-date-using-infile-and-merging-2-files/m-p/715425#M220972</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-01-29T19:30:13Z</dc:date>
    </item>
    <item>
      <title>Re: Reading in csv file with date using infile and merging 2 files with different encoding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-in-csv-file-with-date-using-infile-and-merging-2-files/m-p/715462#M220981</link>
      <description>Thank you!</description>
      <pubDate>Fri, 29 Jan 2021 21:32:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-in-csv-file-with-date-using-infile-and-merging-2-files/m-p/715462#M220981</guid>
      <dc:creator>RLC07</dc:creator>
      <dc:date>2021-01-29T21:32:50Z</dc:date>
    </item>
    <item>
      <title>Re: Reading in csv file with date using infile and merging 2 files with different encoding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-in-csv-file-with-date-using-infile-and-merging-2-files/m-p/715464#M220982</link>
      <description>&lt;P&gt;Thanks for the code; it read in the file properly. Thank you and thanks also for search term for finding info to the second part of my question.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jan 2021 21:34:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-in-csv-file-with-date-using-infile-and-merging-2-files/m-p/715464#M220982</guid>
      <dc:creator>RLC07</dc:creator>
      <dc:date>2021-01-29T21:34:52Z</dc:date>
    </item>
    <item>
      <title>Re: Reading in csv file with date using infile and merging 2 files with different encoding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-in-csv-file-with-date-using-infile-and-merging-2-files/m-p/715466#M220983</link>
      <description>&lt;P&gt;Thanks for the detailed explanation. I included '@' after finding an example code that also suggested I used the&amp;nbsp;&lt;SPAN&gt;ANYDTDTE informat in order to read in dates from a csv in any format. Obviously, it didn't work. Thanks for providing me with the codes - it's been many years since I have used the card statement, but this read in my file accurately. Thanks again!&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jan 2021 21:38:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-in-csv-file-with-date-using-infile-and-merging-2-files/m-p/715466#M220983</guid>
      <dc:creator>RLC07</dc:creator>
      <dc:date>2021-01-29T21:38:52Z</dc:date>
    </item>
    <item>
      <title>Re: Reading in csv file with date using infile and merging 2 files with different encoding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-in-csv-file-with-date-using-infile-and-merging-2-files/m-p/715564#M221025</link>
      <description>&lt;P&gt;If you are going to use mixed encodings then you will want to run your session using UTF-8 encoding. Otherwise it will be impossible to map all of the different characters represented in a different single byte encoding to the single byte encoding that your session is using.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But as long as the source datasets are properly created with the right metadata about what encoding the characters are using you should be able to combine them in your UTF-8 session. One thing to watch out for is whether the strings are defined long enough to store the UTF-8 codes.&amp;nbsp; In a single byte encoding (like WLATIN1 or WLATIN2) each character takes one byte of storage. But when translating to UTF-8 codes some characters take up to 4 bytes.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 30 Jan 2021 17:51:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-in-csv-file-with-date-using-infile-and-merging-2-files/m-p/715564#M221025</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-01-30T17:51:48Z</dc:date>
    </item>
    <item>
      <title>Re: Reading in csv file with date using infile and merging 2 files with different encoding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-in-csv-file-with-date-using-infile-and-merging-2-files/m-p/716207#M221300</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;Thanks for your advice! I ran the session using UTF-8 encoding and merging the two files worked like a charm. What happens if I were to run my session without using SAS 9.4 Unicode Support (e.g. SAS 9.4 English) but specify the encoding (UTF-8 or WLATIN2) when each file is read in and try to merge them? Assuming SAS 9.4 English with encoding specified can support reading in the characters correctly, will I have to convert the encoding for one of the files and make sure they are the same before the merge?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Feb 2021 20:14:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-in-csv-file-with-date-using-infile-and-merging-2-files/m-p/716207#M221300</guid>
      <dc:creator>RLC07</dc:creator>
      <dc:date>2021-02-02T20:14:41Z</dc:date>
    </item>
    <item>
      <title>Re: Reading in csv file with date using infile and merging 2 files with different encoding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-in-csv-file-with-date-using-infile-and-merging-2-files/m-p/716225#M221311</link>
      <description>&lt;P&gt;It depends on the actual characters in the file.&amp;nbsp; If the file is using WLATIN2 and all of the characters that actually appear in the file can be mapped into your current SAS sessions encoding (let's assume that it is using WLATIN1) then you will have no problems. But as soon as one of the input text files has something that is not one of the 256 possible characters supported by WLATIN1 then you will get a null value.&amp;nbsp; Now it the other file you are matching has the same character (prehaps represented in a different encoding) then it will also be mapped to the same strange thing.&amp;nbsp; So the strings will match, but you will get some false positive matches where two string are different in just one character but neither character from the two sources can map into your current encoding.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Feb 2021 21:10:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-in-csv-file-with-date-using-infile-and-merging-2-files/m-p/716225#M221311</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-02-02T21:10:45Z</dc:date>
    </item>
    <item>
      <title>Re: Reading in csv file with date using infile and merging 2 files with different encoding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-in-csv-file-with-date-using-infile-and-merging-2-files/m-p/716945#M221662</link>
      <description>Good to know! Sounds like there is no one straightforward answer other than&lt;BR /&gt;I must get to know and understand my data files. As always, I appreciate&lt;BR /&gt;the time you take to write out a detailed response. Thanks very much!&lt;BR /&gt;</description>
      <pubDate>Fri, 05 Feb 2021 03:07:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-in-csv-file-with-date-using-infile-and-merging-2-files/m-p/716945#M221662</guid>
      <dc:creator>RLC07</dc:creator>
      <dc:date>2021-02-05T03:07:13Z</dc:date>
    </item>
  </channel>
</rss>

