All about DOS style pathnames

For many people who learned to use computers in a Windows (or Mac, for that matter) environment, DOS style pathnames are something of a mystery.  However, they are quite similar to web addresses, and so should not be entirely unfamiliar.

Folders that we see in Windows are graphical representations of a directory tree structure that the computer actually uses to refer to the locations of files.  The syntax used by Windows started before there was a Windows, when IBM-compatible computers ran an operating system called MS-DOS, or DOS for short.  ("MS" stands for Microsoft, and DOS stands for "Disk Operating System.")  At that time, the "path" to a file always had to be typed in, since there were no "pictures" to click on and navigate around the directory.  The same type of pathname, only with enhancements over the years, is still used today to store the location of a file, and tech-savvy users still frequently use this syntax.  Now, Microsoft is getting away from using the term DOS, since whereas you used to open a "DOS Window," they now call it a "Command Prompt."

In DOS, every path starts with a "Drive Letter."  Typically, this corresponds to the name of an actual disk drive in the computer, but it can be other things as well.  Most Windows computers have a "C Drive" that is where the operating system software is found, and usually the various programs that are installed on the machine, too.  The floppy drive is almost always the "A Drive."  Other drives, such as additional hard drives, CD's, USB pen drives, or Network drives, have letter names that vary from one machine to another.

Every drive has a "root" directory.  This is the bottom of the directory structure.  The root of a drive is given by its letter name, a colon, and a back-slash, like "A:\" or "C:\" (the back-slash may sometimes be left off).  Directories and sub-directories (a.k.a. folders and sub-folders) are separated by back-slashes.  There are restrictions on what can be stored in the root directory of a hard drive, so for that reason, and for the purpose of keeping things neatly organized, it is best to create folders in which to store files.  This is not so important for floppies, CD's, or pen drives. 

To get to the root of a drive in Windows, open "My Computer" and double-click the icon of the drive.  This will open a folder that represents the root directory of the drive.  In most Windows systems, opening the C drive folder will bring up a number of sub-folders, among them "WINNT," where the system files are stored, "Program Files," where installed software files are stored, and "Documents and Settings," where files pertaining to individual users are stored.  You are now in the directory "C:\", the root of the C drive, which is probably displayed on the title bar very top of the folder window, as well as in the Address field just above the white part of the folder.

If you double-click one of the folders, such as "Documents and Settings," you effectively change your directory to "C:\Documents and Settings."  You should see the references in the address field and the title bar change accordingly.  This is the pathname of the folder you are viewing.  In this folder we find folders for individual users, usually named according to the log-in account.  We'll just call ours "My Account" for now.  So if you double-click "My Account" and then "My Documents" you should see the address change to "C:\Documents and Settings\My Account\My Documents."  There should appear a list of files, if you have saved any, and folders, if you have created any. 

In DOS, every file had a three-letter extension on its name.  This was a code to tell DOS what type of file it was.  Windows has continued this tradition, although it is possible to have longer extensions, and it is also possible that different kinds of files share the same extension, which is why you sometimes get the "Choose Program" dialog when you want to open a file, and Windows isn't sure what kind of file it is.  Now here's the bad part--there's a setting in Windows that allows you to "hide extensions for known file types."  That means you will not see the extension in the filename listed in your folder, but it is there, nevertheless, and is part of the pathname for that file.  So let's say you have a file called junk.txt in "My Documents."  The pathname of that file is "C:\Documents and Settings\My Account\My Documents\junk.txt."  But if your extensions are hidden, you will just see "junk" with no ".txt" in the folder.  To change this setting, go to the menu at the top of a folder,  click on Tools, then click Folder Options, select the "View" tab, and find the line that says "Hide extensions for known file types."  Deselect the radio button and the extensions will show up.  You can click on "Apply to all Folders" at the top if you want to do that.

To create a folder in Windows, you right-click on the folder you want to create the new one in, then select "New" then "Folder."  You can do this in "My Documents" or in the root of the C Drive (unless it has been restricted) or in a Floppy or any other drive or existing folder.  To keep from having to type too much, we like to create a folder like "C:\sasclass" where we can put our practice files.  To do this, just open "My Computer," click on the drive you want, then create the folder. 

Now, "C:\sasclass," as described above, is a folder suitable for use as a SAS library.  Thus, when you want to refer to it, you can assign it to a libname, like this: libname mylib "C:\sasclass"; and it will be ready to go.  If you have a file, say "junk.txt" in the "sasclass" folder, the pathname for the file is "C:\sasclass\junk.txt", which can be used in an infile statement, for example.