TYPE
Print a text file to SAS output window/.lst file or log
If you want to use TYPE, feel free to download it here:
Download type.sas
If you are not prompted to "Save To Disk", then right-click the link and choose "Save Link Target As..."
Otherwise, you will need to save the web page to your computer. Make sure you save the
type.sas file as a plain text file not an htm/html file.
Disclaimer: There is no warranty on this software either expressed or implied. This program is released under the terms and conditions of GNU General Public License.
About TYPE
Programmer: Dan Blanchette (dan_blanchette@unc.edu)
The Carolina Population Center
The University of North Carolina
Chapel Hill, NC USA
Developed at Research Computing at The University of North Carolina at Chapel Hill
Date: 26February2008
Last updated: 09December2010
Print an ASCII text file SAS output window or "
The Carolina Population Center
The University of North Carolina
Chapel Hill, NC USA
Developed at Research Computing at The University of North Carolina at Chapel Hill
Date: 26February2008
Last updated: 09December2010
Print an ASCII text file SAS output window or "
.lst " file or log
%type("file name and location", options );
Description
The TYPE SAS macro is just like the Stata command (and DOS command)
type. It just prints your text file to the SAS output
window or "
.lst" file or SAS
log. It even has the starbang option that Stata's
type command has that prints only lines that start with
"*!". The SAS command line command fslist and the SAS procedure PROC FSLIST are also very similar to the TYPE SAS macro.Options
NOTE: The parameters have to be specified in the order of this list.
| Parameters | Explanation |
|
(1st)
file name |
Needs to be the text file name and location to print to SAS output or log. |
|
|
|
|
(2nd)
Options |
Explanation |
| -starbang |
It specifies to only print lines that start with "*!" |
| -log |
It specifies to print to the SAS log. The default is to print to the SAS output window/.lst file. |
How to use the TYPE macro:
Using the TYPE macro requires that you understand how to use the %include SAS statement and that you know
how to call a SAS macro.
%include "LOCATION AND NAME OF A FILE THAT CONTAINS SAS CODE";For example, if you have copied this file to "
c:\SASmacros", then you tell SAS
about this macro by adding the following line to your SAS program:
%include "c:\SASmacros\type.sas";The include statement makes SAS aware of the TYPE SAS macro which is in the file type.sas. To use the macro you have to make a call to it. To do that you add a line like the following to your SAS program:
%type("folder & name of an ASCII text file", [options]);
The information inside the parentheses is passed on to the TYPE macro. The first string of information
is the ASCII text file you want to submit to Stata. The second string of information after the comma is the options
you wish to pass on to the TYPE macro.
Examples
%include "C:\SASmacros\type.sas"; ** Include macro once in a SAS session and call it **;
* as many times as you like in that session. **;
** print the text file my_file.txt to SAS output: **;
*%type( file name and location, options ) **;
%type("C:\MyData\my_file.txt", );
** print the text file my_file.txt to SAS log: **;
*%type( file name and location, options ) **;
%type("C:\MyData\my_file.txt", -log );
** only print lines that start with a star and a bang "*!" **;
** in the file C:\MyData\my_file.txt **;
%type("C:\MyData\my_file.txt", -starbang);


