Accessing SAS in Batch Mode

Accessing SAS in Batch Mode

Stat 5411 Fall 2008 Lab 3 Accessing SAS in Batch Mode In lab 1 you ran SAS two different ways: • Using “batch” commands • Using the windows opened by “sas –dms” The batch method is somewhat clumsy, but it works with a minimum of technology setup. You can run this through any terminal connection to the ub computer at UMD. On a PC one option includes Putty which can be downloaded from the UMD Technology Services software website. www.d.umn.edu/Campus Services/ Facilities & Technology/Information Technology/ Services/Software Gets you to http://www.d.umn.edu/itss/software/ Software to download or access online/Secure telnet and ftp clients/Download Putty For example I can connect to ub via wireless service from home. When running Putty the “Hostname” is ub.d.umn.edu You will not be able to open X-windows applications with Putty. For another practice at running SAS in batch mode: To connect to ub on the lab machine • Open the Macintosh HD (hard drive). • Open the Applications folder. • In the utilities folder open the application X11. • At the prompt enter “ssh –X username@ub” (without the “ “ marks and hit Return. o Use your own username, e.g. rregal, the same as your email name. • Enter “yes”when asked if you want to continue connecting. • Enter your password (the same as for email) and hit Return”. • Enter “x” at the prompt asking for the terminal type. • In the UMENU Unix window, type a u or scroll down to “Unix” near the bottom and hit Return. Change to the 5411 directory you created in lab 1. The UNIX command cd means “change directory”. % cd 5411 The following data are weights required to get a 1” bend in brass and steel rods of different lengths, spans of 5” and 13”, bridged across two supports. The columns are: material, span, weight. Brass 5 60 Brass 5 61 Brass 5 65 Brass 13 20 Brass 13 18 Brass 13 18 Steel 5 96 Steel 5 103 Steel 5 99 Steel 13 24 Steel 13 24 Steel 13 25 Now to create the data file called bridge.dat On the ub computer that we are accessing from the lab ub, one way to enter data into a file is with with the pico editor. Enter % pico bridge.dat To create the file bridge.dat. • Enter the data into the file without column headings. o Names for the columns will be given with the “input” statement in the SAS commands. • Note: If you copy/paste from here, you end up with tabs between columns. By default SAS expects “white space” spaces, not tabs. You need to delete the tabs and replace them with spaces. • The pico commands are shown at the bottom of the screen. • Exit pico with ^x. meaning holding the control key and "x" at the same time. o Enter "y" in answer to "Save modified buffer ...". o Type Enter key to accept the name bridge.dat as the name of the file. Confirm that the file was created by listing the saved files. % ls ls is the UNIX command to list all file names. Now print the file to the screen just to be sure it’s ok. % more bridge.dat For a short file like this, it all fits onto one page. In general type the enter key to get the next page. Typing "q" quits right then. Now create the SAS command file called bridge.sas % pico bridge.sas Enter these commands into the file and exit with ^x, control-x, as before. options ls=80; libname here '.'; data here.bridge; title 'My Name Lab 3'; infile 'bridge.dat'; input material $ span weight; ln_weight = log(weight); * In SAS this the natural log. Log base 10 is log10(weight); proc print; goptions device=pdfc gsfmode=append gsfname=grafout; filename grafout 'bridge.pdf'; axis2 logbase=10; proc gplot; plot weight*span=material; plot weight*span=material/vaxis=axis2; run; The options and filename statements create the plots in a color pdf (pdfc device driver) file. To plot data, we can use procedure “plot” or procedure “gplot”. • plot produces simple typewriter type plots in the output window. o These are handy for quick looks at the data and if you are running SAS in batch mode where you can’t open graphics windows. • gplot produces prettier graphs for a particular graphics device. o By default graphs pop up in a Graphics window. o You can set the device as above to other options such as pdfc, color pdf. o If you tried running the SAS commands without specifying where to send the graphs, you would get a question of what device to use. If for example you type ps in response, you would get a PostScript file or whatever device you specify. To run SAS use the command % sas bridge By default "sas xx" means run the commands in xx.sas Running sas creates at least one and hopefully three files. The file bridge.log has information on what happened when running bridge.sas. If there were any errors, the error messages are in bridge.log. Unfortunately, SAS error statements are not very clear. A common problem is to forget a semicolon delimiter, after which SAS is just confused. The error message doesn’t come until the line where SAS finally finds a semicolon. An error early in the run can cascade to further errors later. Sometimes it works best to fix the first error message's problem, and then run again. Look at bridge.log % more bridge.log Usually NOTE comments in the log file are fine. If there are any ERROR comments listed in the log file, fix any problems in bike.sas using pico, and rerun the commands with "sas bridge". The file bridge.lst has output created by the run, unless errors kept the output from being created. It's best to check the .log file before the .lst file to make sure there weren't error problems or important warnings in the run. See if the .lst file and the pdf file were created. % ls If all went well, the file bridge.lst is listed. If not, fix any problems in bridge.sas using pico, and rerun the commands with "sas bridge". If the .lst file is there, look at the file, this time with pico. % pico bridge.lst The printed data should match the bridge data shown above. Another way to get data into SAS is to include the data with the command file. The following could be put into bridge.sas and run as usual with % sas bridge options ls=80; libname here '.'; data here.bridge; title 'My Name Lab 3'; input material $ span weight; datalines; Brass 5 60 Brass 5 61 Brass 5 65 Brass 13 20 Brass 13 18 Brass 13 18 Steel 5 96 Steel 5 103 Steel 5 99 Steel 13 24 Steel 13 24 Steel 13 25 ; proc print; run; Transferring files to and from ub and the Mac Now we will transfer the pdf file from ub to the Mac. On the Macintosh choose • Lab Apps • Internet • Fetch (double click) (or use the doggie at bottom of the screen) • File/New Connection • Hostname: ub.d.umn.edu • Username/Password Double click your 5411 directory which you created earlier The file bridge.pdf should be listed. • Drag the bridge.pdf file to the Mac desktop. • Double click the pdf file to look at the plots Viewing these plots of the data we can see how the data turned out. One conclusion is that in the log scale the variances are more constant. The plotting symbols in the plot aren’t very striking. In the next exercise we will create plots with more control over the plotting symbols. Email your self the bridge.pdf file as an attachment • pine • Specify the attachment as 5411/bridge.pdf. o If this works, the attachment name will be expanded to include the size of the file being attached. Plotting in the windowed display from “sas –dms” An Excel file syrup.xls was imported to SAS on my PC version of SAS with the following commands. Note: This is not an Excel 2007 file. proc import replace datafile="F:\5411_current_2008\Labs\syrup.xls" out=labs.syrup; sheet='data'; Unfortunately for, the UNIX version doesn’t do this Excel conversion except through a server. To see how the Excel file started out, open a web browser to http://www.d.umn.edu/~rregal1/documents/5411/syrup.xls Save the file. This ends up on the desktop. Open the Excel file on the desktop and look at the data sheet as well as the graph sheet. These data are better analyzed in the log scale, partly because of constant variances but also for some better reasons we will cover later. In Excel you can change an axis scale to a log scale with the values labeled in the original scale by changing one of the options for the axis format. Excel however, requires that the axis limits be powers of 10 which is sometimes not great. SAS and other graphing programs allow more versatility. Now using the UNIX copy command, cp, copy a file of SAS commands and SAS data file from my directory to your UNIX 5411 directory and make sure the file got there. (You should still be in the 5411 directory. You can always check this with the “print working directory command: pwd.) • cp /home/volh/14/rregal/5411/syrup.sas syrup.sas • cp /home/volh/14/rregal/5411/syrup.sas7bdat syrup.sas7bdat • cp /home/volh/14/rregal/5411/turtle.sas7bdat turtle.sas7bdat • ls Now open the windowed access to SAS • sas –dms An X window should be opened automatically.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    11 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us