<?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: How to infile and merge many tab delimitered csv files named with dates and with num and char va in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-infile-and-merge-many-tab-delimitered-csv-files-named/m-p/599618#M173114</link>
    <description>&lt;P&gt;Please post the first 5 (or so) lines of one of the infiles. Copy/paste into a window opened with the {i} button.&lt;/P&gt;</description>
    <pubDate>Sun, 27 Oct 2019 09:26:55 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2019-10-27T09:26:55Z</dc:date>
    <item>
      <title>How to infile and merge many tab delimitered csv files named with dates and with num and char vars?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-infile-and-merge-many-tab-delimitered-csv-files-named/m-p/599616#M173113</link>
      <description>&lt;P&gt;I have 365 tab delimitered csv files, all have the same&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="lia-search-match-lithium"&gt;data&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;structure (same variable names) and the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="lia-search-match-lithium"&gt;file&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;names are like&amp;nbsp;&lt;/P&gt;
&lt;P&gt;exp20180101.csv&amp;nbsp;&lt;/P&gt;
&lt;P&gt;.......&lt;/P&gt;
&lt;P&gt;exp20181231.csv&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The data files contains both numeric variables and character variables, the observations of character variables are of different length but all are less than 50 characters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="lia-search-match-lithium"&gt;import&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;and merge them into a single&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="lia-search-match-lithium"&gt;file&lt;/SPAN&gt;. I searched this community and find a similar question. I use the codes they provide,but the infiled character variables are not correct.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data import_all;
 
*make sure variables to store file name are long enough;
length filename txt_file_name $256;
 
*keep file name from record to record;
retain txt_file_name;
 
*Use wildcard in input;
infile "F:\source data\*.csv" eov=eov filename=filename truncover dlm='09'x;
 
*Input first record and hold line;
input@;
 
*Check if this is the first record or the first record in a new file;
*If it is, replace the filename with the new file name and move to next line;
if _n_ eq 1 or eov then do;
txt_file_name = scan(filename, -1, "\");
eov=0;
end;
 
*Otherwise  go to the import step and read the files;

input x1-x5 (x6-x25) (:$50.)  x26-x45;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="result.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/33426i229BAE87718416E7/image-size/large?v=v2&amp;amp;px=999" role="button" title="result.png" alt="result.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;can anyone give me some hints about what's wrong with my codes?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you very much!&lt;/P&gt;</description>
      <pubDate>Sun, 27 Oct 2019 09:02:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-infile-and-merge-many-tab-delimitered-csv-files-named/m-p/599616#M173113</guid>
      <dc:creator>owenwqp1</dc:creator>
      <dc:date>2019-10-27T09:02:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to infile and merge many tab delimitered csv files named with dates and with num and char va</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-infile-and-merge-many-tab-delimitered-csv-files-named/m-p/599618#M173114</link>
      <description>&lt;P&gt;Please post the first 5 (or so) lines of one of the infiles. Copy/paste into a window opened with the {i} button.&lt;/P&gt;</description>
      <pubDate>Sun, 27 Oct 2019 09:26:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-infile-and-merge-many-tab-delimitered-csv-files-named/m-p/599618#M173114</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-10-27T09:26:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to infile and merge many tab delimitered csv files named with dates and with num and char va</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-infile-and-merge-many-tab-delimitered-csv-files-named/m-p/599619#M173115</link>
      <description>&lt;P&gt;Thanks for your help! KurtBremser&lt;/P&gt;
&lt;PRE&gt;"719024869	20170101	201701	2017	2017.0027	AGR	FARMER						AGR			CAN	CANADA	CAN								1	061	061	06	2	6.4	12	6	12	-2.8393711501275	2	Minnesota"	" United States	US	USMN	45.7326	-93.9196	MN	1	Mexico	MX	MX	23	-102	MX	2	Minnesota"	" United States	US	USMN	45.7326	-93.9196	MN	20180101	http://www.kansas.com/news/business/article192357844.html"								
"719024870	20170101	201701	2017	2017.0027	AGR	FARMER						AGR			CAN	CANADA	CAN								1	061	061	06	2	6.4	36	6	36	-2.8393711501275	1	Mexico	MX	MX	23	-102	MX	1	Canada	CA	CA	60	-96	CA	1	Mexico	MX	MX	23	-102	MX	20180101	http://www.kansas.com/news/business/article192357844.html"										
"719024871	20170101	201701	2017	2017.0027	AGR	FARMER						AGR			CAN	CANADA	CAN								1	061	061	06	2	6.4	12	6	12	-2.8393711501275	1	Mexico	MX	MX	23	-102	MX	1	Mexico	MX	MX	23	-102	MX	1	Mexico	MX	MX	23	-102	MX	20180101	http://www.kansas.com/news/business/article192357844.html"										
"719024872	20170101	201701	2017	2017.0027	AGR	FARMER						AGR			MEX	MEXICO	MEX								1	061	061	06	2	6.4	12	6	12	-2.8393711501275	2	Minnesota"	" United States	US	USMN	45.7326	-93.9196	MN	2	Minnesota"	" United States	US	USMN	45.7326	-93.9196	MN	2	Minnesota"	" United States	US	USMN	45.7326	-93.9196	MN	20180101	http://www.kansas.com/news/business/article192357844.html"							
"719024873	20170101	201701	2017	2017.0027	AGR	FARMER						AGR			MEX	MEXICO	MEX								1	061	061	06	2	6.4	48	6	48	-2.8393711501275	1	Mexico	MX	MX	23	-102	MX	1	Mexico	MX	MX	23	-102	MX	1	Mexico	MX	MX	23	-102	MX	20180101	http://www.kansas.com/news/business/article192357844.html"										
"719024874	20170101	201701	2017	2017.0027	USA	UNITED STATES	USA								USAGOV	THE WHITE HOUSE	USA					GOV			1	130	130	13	3	-4.4	14	2	14	-4.7522003466853	3	White House"	 District of Columbia	" United States	US	USDC	38.8951	-77.0364	531871	3	White House"	 District of Columbia	" United States	US	USDC	38.8951	-77.0364	531871	3	White House"	 District of Columbia	" United States	US	USDC	38.8951	-77.0364	531871	20180101	http://www.independent.co.uk/news/world/americas/president-donald-trump-white-house-first-year-inauguration-federal-bureaucracy-barack-obama-a8135921.html"				
"719024875	20171202	201712	2017	2017.9096											USA	MISSOURI	USA								1	043	043	04	1	2.8	36	6	36	-2.56410256410256	0							2	Missouri"	" United States	US	USMO	38.4623	-92.302	MO	1	Mexico	MX	MX	23	-102	MX	20180101	http://www.TucsonNewsNow.com/story/37167033/dog-missing-for-a-year-turns-up-4-states-away"									
"719024876	20171202	201712	2017	2017.9096	COP	POLICE						COP			AUS	MELBOURNE	AUS								0	130	130	13	3	-4.4	10	1	10	-9.765625	4	Brunswick West"	 Victoria	" Australia	AS	AS07	-37.7833	144.933	-1562136	4	Melbourne"	 Victoria	" Australia	AS	AS07	-37.8167	144.967	-1586844	4	Brunswick West"	 Victoria	" Australia	AS	AS07	-37.7833	144.933	-1562136	20180101	http://www.heraldsun.com.au/news/victoria/three-men-burnt-while-using-illegal-fireworks-to-bring-in-2018/news-story/3f19242cc5fda5181931965d81fc1626?nk=0a819496d71c943b20ea7f7092959275-1514764002"				
"719024877	20171202	201712	2017	2017.9096	COP	POLICE						COP			AUS	MELBOURNE	AUS								0	130	130	13	3	-4.4	46	4	46	-10.2798874684749	4	Melbourne"	 Victoria	" Australia	AS	AS07	-37.8167	144.967	-1586844	4	Melbourne"	 Victoria	" Australia	AS	AS07	-37.8167	144.967	-1586844	4	Melbourne"	 Victoria	" Australia	AS	AS07	-37.8167	144.967	-1586844	20180101	http://www.heraldsun.com.au/news/victoria/three-men-burnt-while-using-illegal-fireworks-to-bring-in-2018/news-story/3f19242cc5fda5181931965d81fc1626?nk=0a819496d71c943b20ea7f7092959275-1514764002"				
"719024878	20171202	201712	2017	2017.9096	COP	POLICE						COP			AUS	MELBOURNE	AUS								0	173	173	17	4	-5.0	10	1	10	-9.765625	4	Brunswick West"	 Victoria	" Australia	AS	AS07	-37.7833	144.933	-1562136	4	Melbourne"	 Victoria	" Australia	AS	AS07	-37.8167	144.967	-1586844	4	Melbourne"	 Victoria	" Australia	AS	AS07	-37.8167	144.967	-1586844	20180101	http://www.heraldsun.com.au/news/victoria/three-men-burnt-while-using-illegal-fireworks-to-bring-in-2018/news-story/3f19242cc5fda5181931965d81fc1626?nk=0a819496d71c943b20ea7f7092959275-1514764002"				
"719024879	20171202	201712	2017	2017.9096	COP	POLICE						COP			AUS	MELBOURNE	AUS								0	173	173	17	4	-5.0	46	4	46	-10.2798874684749	4	Melbourne"	 Victoria	" Australia	AS	AS07	-37.8167	144.967	-1586844	4	Melbourne"	 Victoria	" Australia	AS	AS07	-37.8167	144.967	-1586844	4	Melbourne"	 Victoria	" Australia	AS	AS07	-37.8167	144.967	-1586844	20180101	http://www.heraldsun.com.au/news/victoria/three-men-burnt-while-using-illegal-fireworks-to-bring-in-2018/news-story/3f19242cc5fda5181931965d81fc1626?nk=0a819496d71c943b20ea7f7092959275-1514764002"				
"719024880	20171202	201712	2017	2017.9096	USA	MISSOURI	USA																		1	042	042	04	1	1.9	36	6	36	-2.56410256410256	2	Missouri"	" United States	US	USMO	38.4623	-92.302	MO	0							1	Mexico	MX	MX	23	-102	MX	20180101	http://www.TucsonNewsNow.com/story/37167033/dog-missing-for-a-year-turns-up-4-states-away"									
"719024881	20171225	201712	2017	2017.9726											RUS	RUSSIA	RUS								1	042	042	04	1	1.9	2	1	2	-6.41711229946524	0							3	Allegheny County"	 Pennsylvania	" United States	US	USPA	40.6253	-80.1251	1213657	3	Allegheny County"	 Pennsylvania	" United States	US	USPA	40.6253	-80.1251	1213657	20180101	http://www.njherald.com/article/20171231/AP/312319872"						
"719024882	20171225	201712	2017	2017.9726	GOV	SECURITY COUNCIL						GOV			PRK	PYONGYANG	PRK								0	163	163	16	4	-8.0	2	1	2	-3.2258064516129	1	Russia	RS	RS	60	100	RS	4	Pyongyang"	 P'yongyang-si	" North Korea	KN	KN12	39.0194	125.755	-183459	1	Russia	RS	RS	60	100	RS	20180101	https://www.channelnewsasia.com/news/world/after-trump-criticism--china-denies-selling-oil-illicitly-to-north-korea-9819368"								
"719024883	20171231	201712	2017	2017.9890											GOV	PRESIDENT						GOV			1	020	020	02	1	3.0	6	1	6	-2.40963855421687	0							4	Ibadan"	 Oyo	" Nigeria	NI	NI32	7.38778	3.89639	-2010458	4	Ibadan"	 Oyo	" Nigeria	NI	NI32	7.38778	3.89639	-2010458	20180101	https://blueprint.ng/2018-enough-of-blame-game-asuu-tells-buhari/"						
&lt;/PRE&gt;</description>
      <pubDate>Sun, 27 Oct 2019 09:56:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-infile-and-merge-many-tab-delimitered-csv-files-named/m-p/599619#M173115</guid>
      <dc:creator>owenwqp1</dc:creator>
      <dc:date>2019-10-27T09:56:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to infile and merge many tab delimitered csv files named with dates and with num and char va</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-infile-and-merge-many-tab-delimitered-csv-files-named/m-p/599628#M173118</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input fname $80.;
infile dummy filevar=fname end=last dsd truncover dlm='09'x;
do while(not last);
 input x1-x5 (x6-x25) (:$50.)  x26-x45;
 output;
end;
cards;
F:\source data\exp20180101.csv 
.......
F:\source data\exp20181231.csv
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 27 Oct 2019 11:42:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-infile-and-merge-many-tab-delimitered-csv-files-named/m-p/599628#M173118</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-10-27T11:42:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to infile and merge many tab delimitered csv files named with dates and with num and char va</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-infile-and-merge-many-tab-delimitered-csv-files-named/m-p/599647#M173126</link>
      <description>&lt;P&gt;You forgot the DSD option on the INFILE statement. That will allow it to read empty values properly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Normally SAS uses space as a delimiter.&amp;nbsp; And normally space delimited files use extra spaces to make the columns line up.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Name       Age    Height
Alfred      14     69.0
Alice       13     56.5
Barbara     13     65.3&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So SAS will treat 2 or more spaces in a row as the same on one space in terms or indicating the end/start of a word to read.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But with a real delimited file you use adjacent delimiters to indicate when a value is missing.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Name,Age,Height
Alfred,14,69.0
Alice,,56.5
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 27 Oct 2019 15:25:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-infile-and-merge-many-tab-delimitered-csv-files-named/m-p/599647#M173126</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-10-27T15:25:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to infile and merge many tab delimitered csv files named with dates and with num and char va</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-infile-and-merge-many-tab-delimitered-csv-files-named/m-p/599649#M173128</link>
      <description>&lt;P&gt;Thanks a lot! Tom, you're so helpful!&lt;/P&gt;</description>
      <pubDate>Sun, 27 Oct 2019 16:12:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-infile-and-merge-many-tab-delimitered-csv-files-named/m-p/599649#M173128</guid>
      <dc:creator>owenwqp1</dc:creator>
      <dc:date>2019-10-27T16:12:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to infile and merge many tab delimitered csv files named with dates and with num and char va</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-infile-and-merge-many-tab-delimitered-csv-files-named/m-p/599650#M173129</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;Ksharp!&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; Your codes works! The only inconvenience is the long cards.&lt;/P&gt;</description>
      <pubDate>Sun, 27 Oct 2019 16:16:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-infile-and-merge-many-tab-delimitered-csv-files-named/m-p/599650#M173129</guid>
      <dc:creator>owenwqp1</dc:creator>
      <dc:date>2019-10-27T16:16:51Z</dc:date>
    </item>
  </channel>
</rss>

