<?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 How do I split my data set into multiple files?  second in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-split-my-data-set-into-multiple-files-second/m-p/427161#M105319</link>
    <description>&lt;P&gt;Sorry about this but my replies were for some reason taken for review and needs to wait for approvals from the board for my previous question thread (&lt;A href="https://communities.sas.com/t5/Base-SAS-Programming/How-do-I-split-my-data-set-into-multiple-files/m-p/426885/highlight/false#M105221" target="_blank"&gt;https://communities.sas.com/t5/Base-SAS-Programming/How-do-I-split-my-data-set-into-multiple-files/m-p/426885/highlight/false#M105221&lt;/A&gt;)&lt;/P&gt;&lt;P&gt;The question is the same...&amp;nbsp; I need to split file (Text file) into smaller files in order to process them. Many thanks to RW9 and Tom. I am now able to split the files as Tom suggested.&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;create &lt;SPAN class="token statement"&gt;table&lt;/SPAN&gt; tmp as
 &lt;SPAN class="token statement"&gt;select&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;from&lt;/SPAN&gt; connection to sqlserver
  &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token statement"&gt;select&lt;/SPAN&gt;
      substring&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;cast&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;bigfile_xml as nvarchar&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;max&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;17000&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; as XMLCol1
    &lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; substring&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;cast&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;bigfile_xml as nvarchar&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;max&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;17001&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;17000&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; as XMLCol2
    &lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; substring&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;cast&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;bigfile_xml as nvarchar&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;max&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;34001&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;17000&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; as XMLCol3
&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;
   &lt;SPAN class="token keyword"&gt;from&lt;/SPAN&gt;
      bigfile
  &lt;SPAN class="token statement"&gt;where&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;id&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
   &lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;However, I was hoping for a way to also allow the code to derive an appropriate number of variables needed as the number of characters in each observation could be different.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried writing a code into it but it didn't work. I'd appreciate any pointers on where I went wrong or what I should do.&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let BigfileC= CountC(bigfile_xml);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; *CountC can be used to count characters instead of words.;&lt;/P&gt;&lt;P&gt;%let chunks = round(BigfileC/32000);&amp;nbsp;&amp;nbsp; *i'm trying to round it up so I know how many chunks I need for it ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I = chunks;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;* trying to set a value to I for the DO LOOP;&lt;/P&gt;&lt;P&gt;Array Text(I);&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;* didnt think I needed Array but errors suggest I do;&lt;/P&gt;&lt;P&gt;Do I = 0 to chunks;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * I'm thinking a DO LOOP would be a possible method for this splitting?;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then finally I can just apply these into the code Tom suggested&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Substring&lt;/EM&gt;(cast(bigfile_xml as nvarchar(max)),I*17000+1,(I+1)*17000) as XMLCol(I) ;&amp;nbsp;&amp;nbsp; * This is how I thought would help create the files.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This doesn't work. Please help. and sorry for the second thread but Services told me I might have to wait a long time before they approve my reply in my previous thread...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 12 Jan 2018 11:59:27 GMT</pubDate>
    <dc:creator>AlexMoreton</dc:creator>
    <dc:date>2018-01-12T11:59:27Z</dc:date>
    <item>
      <title>How do I split my data set into multiple files?  second</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-split-my-data-set-into-multiple-files-second/m-p/427161#M105319</link>
      <description>&lt;P&gt;Sorry about this but my replies were for some reason taken for review and needs to wait for approvals from the board for my previous question thread (&lt;A href="https://communities.sas.com/t5/Base-SAS-Programming/How-do-I-split-my-data-set-into-multiple-files/m-p/426885/highlight/false#M105221" target="_blank"&gt;https://communities.sas.com/t5/Base-SAS-Programming/How-do-I-split-my-data-set-into-multiple-files/m-p/426885/highlight/false#M105221&lt;/A&gt;)&lt;/P&gt;&lt;P&gt;The question is the same...&amp;nbsp; I need to split file (Text file) into smaller files in order to process them. Many thanks to RW9 and Tom. I am now able to split the files as Tom suggested.&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;create &lt;SPAN class="token statement"&gt;table&lt;/SPAN&gt; tmp as
 &lt;SPAN class="token statement"&gt;select&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;from&lt;/SPAN&gt; connection to sqlserver
  &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token statement"&gt;select&lt;/SPAN&gt;
      substring&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;cast&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;bigfile_xml as nvarchar&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;max&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;17000&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; as XMLCol1
    &lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; substring&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;cast&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;bigfile_xml as nvarchar&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;max&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;17001&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;17000&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; as XMLCol2
    &lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; substring&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;cast&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;bigfile_xml as nvarchar&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;max&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;34001&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;17000&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; as XMLCol3
&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;
   &lt;SPAN class="token keyword"&gt;from&lt;/SPAN&gt;
      bigfile
  &lt;SPAN class="token statement"&gt;where&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;id&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
   &lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;However, I was hoping for a way to also allow the code to derive an appropriate number of variables needed as the number of characters in each observation could be different.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried writing a code into it but it didn't work. I'd appreciate any pointers on where I went wrong or what I should do.&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let BigfileC= CountC(bigfile_xml);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; *CountC can be used to count characters instead of words.;&lt;/P&gt;&lt;P&gt;%let chunks = round(BigfileC/32000);&amp;nbsp;&amp;nbsp; *i'm trying to round it up so I know how many chunks I need for it ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I = chunks;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;* trying to set a value to I for the DO LOOP;&lt;/P&gt;&lt;P&gt;Array Text(I);&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;* didnt think I needed Array but errors suggest I do;&lt;/P&gt;&lt;P&gt;Do I = 0 to chunks;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * I'm thinking a DO LOOP would be a possible method for this splitting?;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then finally I can just apply these into the code Tom suggested&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Substring&lt;/EM&gt;(cast(bigfile_xml as nvarchar(max)),I*17000+1,(I+1)*17000) as XMLCol(I) ;&amp;nbsp;&amp;nbsp; * This is how I thought would help create the files.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This doesn't work. Please help. and sorry for the second thread but Services told me I might have to wait a long time before they approve my reply in my previous thread...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2018 11:59:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-split-my-data-set-into-multiple-files-second/m-p/427161#M105319</guid>
      <dc:creator>AlexMoreton</dc:creator>
      <dc:date>2018-01-12T11:59:27Z</dc:date>
    </item>
    <item>
      <title>Re: How do I split my data set into multiple files?  second</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-split-my-data-set-into-multiple-files-second/m-p/427162#M105320</link>
      <description>&lt;P&gt;I would also need to combine them together again after cleaning the data so if anyone have any idea on the best way to combine/merge them again (i've been looking into UNION and MERGE right now). please let me know.&lt;/P&gt;&lt;P&gt;As of now the string is not broken into different columns/ variables which UNION does not seem to be working...&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2018 12:07:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-split-my-data-set-into-multiple-files-second/m-p/427162#M105320</guid>
      <dc:creator>AlexMoreton</dc:creator>
      <dc:date>2018-01-12T12:07:57Z</dc:date>
    </item>
    <item>
      <title>Re: How do I split my data set into multiple files?  second</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-split-my-data-set-into-multiple-files-second/m-p/427174#M105324</link>
      <description>&lt;P&gt;Not sure I follow you.&amp;nbsp; First you are not able to combine the variables back into one in a SAS dataset, SAS Datasets have a limit of 2000 characters per variable.&lt;/P&gt;
&lt;P&gt;Also, its rarely a good idea to put data items across the page (called transposed) as this just makes working with the data far more difficult.&amp;nbsp; Create an observation for each break so you have a list of data in one column, you will find it much easier to write code this way.&lt;/P&gt;
&lt;P&gt;Why do you need to combine this data again?&amp;nbsp; Is it just to write to a file, if so have your observations and just put them out to a file.&amp;nbsp; If you want to do analysis, then consider breaking the data up into a usable format.&lt;/P&gt;
&lt;P&gt;As we have yet to see anything in the way of inputs or what you want out, its impossible to tell you have to do the middle bit.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2018 13:14:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-split-my-data-set-into-multiple-files-second/m-p/427174#M105324</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-01-12T13:14:05Z</dc:date>
    </item>
    <item>
      <title>Re: How do I split my data set into multiple files?  second</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-split-my-data-set-into-multiple-files-second/m-p/427177#M105326</link>
      <description>&lt;P&gt;Hi RW9,&lt;/P&gt;&lt;P&gt;The file is a text file (as you suggested) and the string itself is roughly 50k - 100k characters long.&lt;/P&gt;&lt;P&gt;I am calling the data from a SQL server (as a result I was not sure what file type it was/is but i think its text file as it matched your description). For the purpose of my project I am to break the string (retrieved from sql server using select from) down into smaller chunks and run cleansing for all of them and then export them as a single XML file with all of them combined. The file that is retrieved is literally one single observations of a string of characters.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The idea of breaking the string via observation so I only end up&amp;nbsp;a list of data with only one column was what I wanted. But as I was unable to create a code to do anything... Breaking it into variables became the next best thing... I do not know how to code it to break via observations based on character numbers (as I still want to be able to know how many characters each file has (different text files will have different lengths).&lt;/P&gt;&lt;P&gt;&amp;nbsp;Please tell me what more information you need and I will try and supply them to you.&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2018 13:26:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-split-my-data-set-into-multiple-files-second/m-p/427177#M105326</guid>
      <dc:creator>AlexMoreton</dc:creator>
      <dc:date>2018-01-12T13:26:45Z</dc:date>
    </item>
    <item>
      <title>Re: How do I split my data set into multiple files?  second</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-split-my-data-set-into-multiple-files-second/m-p/427184#M105329</link>
      <description>&lt;P&gt;I provided code:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/Base-SAS-Programming/How-do-I-split-my-data-set-into-multiple-files/m-p/426887#M105222" target="_blank"&gt;https://communities.sas.com/t5/Base-SAS-Programming/How-do-I-split-my-data-set-into-multiple-files/m-p/426887#M105222&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, as you seem to be using SQL and mentioning SQL server, it sounds like your taking data from a database.&amp;nbsp; This is not the same as for a text file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We seem to be getting the wrong end of the stick here. There are three processes involved here as I see it:&lt;/P&gt;
&lt;P&gt;1) Read the data from the database into a dataset -&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt; has provided code to do this, and you get a dataset with lots of variables yes?&amp;nbsp; I still don't see why you get one long text string, does it not have delimiters or breaks or something?&lt;/P&gt;
&lt;P&gt;2) Process this data to "cleanse it" - no information here so can't help&lt;/P&gt;
&lt;P&gt;3) Write this final dataset out to an XML file.&amp;nbsp; This should be quite simple:&lt;/P&gt;
&lt;PRE&gt;data _null_;
  file "c:\want.xml";
  set have;
  put "&amp;lt;xml version=1.2&amp;gt;";
  put "&amp;lt;dataset&amp;gt;";
  put _all_;
  put "&amp;lt;/dataset&amp;gt;"; 
run;
  &lt;/PRE&gt;
&lt;P&gt;This is just an example of writing a text file with some tags to be an XML file.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2018 13:38:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-split-my-data-set-into-multiple-files-second/m-p/427184#M105329</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-01-12T13:38:45Z</dc:date>
    </item>
    <item>
      <title>Re: How do I split my data set into multiple files?  second</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-split-my-data-set-into-multiple-files-second/m-p/427187#M105331</link>
      <description>&lt;P&gt;Hi RW9,&lt;/P&gt;&lt;P&gt;I have tried your code but as it seems that I cannot save the file into a library first as the it does not contain all the characters.&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I worked Tom's code, I was able to find the complete code separated into 5 columns (not rows...).&amp;nbsp;&lt;/P&gt;&lt;P&gt;So in this sense I was unable to follow your code due to the inability to use the FILE ' ' step.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried the code with a dummy file that consisted 90K characters but an error comes out.&lt;/P&gt;&lt;P&gt;ERROR: Either a CARDS or an INFILE statement is required&lt;/P&gt;&lt;P&gt;this was the code i used:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;file 'Y:\My Docs\Alex\TEST.txt';&lt;BR /&gt;length line $2000;&lt;BR /&gt;input a $char1.;&lt;BR /&gt;line=cat(line,a);&lt;BR /&gt;if lengthn(line) &amp;gt; 1999 then do;&lt;BR /&gt;output;&lt;BR /&gt;line="";&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In terms of cleansing, basically the string contained "bad characters that could not be read" so I need to basically find and replace them.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2018 13:51:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-split-my-data-set-into-multiple-files-second/m-p/427187#M105331</guid>
      <dc:creator>AlexMoreton</dc:creator>
      <dc:date>2018-01-12T13:51:20Z</dc:date>
    </item>
    <item>
      <title>Re: How do I split my data set into multiple files?  second</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-split-my-data-set-into-multiple-files-second/m-p/427189#M105333</link>
      <description>&lt;P&gt;Don't bother. Just check the database definition or SQLServer documentation for what is the longest string that your CLOB can contain and write the code to handle that.&amp;nbsp; SAS (or you) will not care if the last 10 variables are all blanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If SQL server complains about using a SUBSTR starting location or length that is longer than the input string then use CASE statement.&amp;nbsp; You will need to find the&amp;nbsp;SQLserver function that returns the length of the CLOB string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2018 14:01:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-split-my-data-set-into-multiple-files-second/m-p/427189#M105333</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-01-12T14:01:53Z</dc:date>
    </item>
  </channel>
</rss>

