Date: Sun, 17 Oct 2004 06:14:16 GMT
Reply-To: Alan Churchill <REM0VETHISSTRINGTechSupport@SAVIAN.NET>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Alan Churchill <REM0VETHISSTRINGTechSupport@SAVIAN.NET>
Subject: Re: DCB-information on a PC-file
When I write a file on a PC, the PC automatically creates carriage returns and linefeeds by default. The lines are adjusted as needed. Most of the time, PC files are not fixed length but variable and these can be adjusted in any decent editor.
The writing of the file is handled by calls to the operating system and it, by default, performs certain actions such as linefeeds and eof markers. However, you can control these if needed.
Here is an example of writing a file but handling some of the characteristics available. The code is in C# but I think it is pretty easy to follow. You can do something similar in SAS:
//Create a new streamwriter called ‘writer'. Point to the file ‘test.txt', do not append, use Unicode as the
//output. Unicode, unlike ASCII and EBCDIC, supports more characters and therefore is more universal.
StreamWriter writer=new StreamWriter(@"c:\temp\test.txt",false,System.Text.Encoding.Unicode) ;
writer.Write("string without newline") ;
//Write a single newline
//Loop and write 10 times
for (int i=0;i<10;i++)
writer.WriteLine("string " + i.ToString() + " with newline") ;
//Write a chain of strings without newlines
for (int i=0;i<10;i++)
writer.Write("string " + i.ToString()) ;
//Write an end of file and close the file
Here is the resulting output:
string without newline
string 0 with newline
string 1 with newline
string 2 with newline
string 3 with newline
string 4 with newline
string 5 with newline
string 6 with newline
string 7 with newline
string 8 with newline
string 9 with newline
string 0string 1string 2string 3string 4string 5string 6string 7string 8string 9
"Bridging SAS and Microsoft technologies"
Thanks for your reply, I will study the article.
When writing to a simple text-file on a mainframe, you usually specify
the DCB-details for the file before writing. I don't understand how
the PC takes care of this automatically. How are record-length,
end-of-line markers etc. handled, if you don't specify this?
Guess I will have to read the article before asking more questions :-)
"Alan Churchill" <REM0VETHISSTRINGTechSupport@savian.net> wrote in message news:<_g3cd.924$dZ.email@example.com>...
> The file system handles it all for you on a PC. A possible source of info:
> It really depends on what you are trying to do. I think a question along those lines might be easier to answer.
> Bear with me since it has been a few years since my MVS days and
coding DCBs…but on the mainframe, all resources need to be
allocated prior to use. The PC operates very differently in that
resources are demanded and received on the fly. Hence you have static
information, at that time, about a file but there aren't caps per se
on what it can hold. Also, I can call a picture a .gif or a .txt: the
extension is merely a ‘suggestion' but the file system
determines the type based upon an event (user click saying ‘open
this in an image editor) or a binary representation in the file.
> The article above describes accessing the file system for the info but I would be leery of going down this route w/o knowing more about what you are trying to do. SAS has some insights into the file system however there are other ways of getting much more information (including going through SAS to an O\S type of command).
> "Bridging SAS and Microsoft technologies"
> On a mainframe-file I am used to specify a number of DCB-informations
> about a file, e.g. record length (LRECL), record format (VB, VBA, FB),
> block size (BLKSIZE) etc.
> But what about a PC-file? Is this information kept in the file-type,
> e.g. .txt, .doc, .xls, .sas etc.? Can't be the whole truth.
> How are PC-files in general organized (text- vs. binary-files etc.),
> and how do I retrieve this information?