INSTRUCTIONS FOR USING SAS ON WINDOWS To begin, choose the "SAS System for Windows" under "Start" and "Programs" or on the desktop. SAS will begin to run, and an interface with three windows (Program Editor, Log, and Output) will appear. You can access any of the windows by clicking on the appropriate bar at the bottom, or by looking under the View menu. The Program Editor is where the SAS commands are typed. The Output window is where the results appear. The Log window is useful for finding errors in the SAS code. Once your SAS program is typed in the Program Editor window, you run the program. This is done by choosing "Submit" under the "Run" menu, or by pressing the F3 button. (If the SAS code in the Program Editor is erased upon running it, you can, after clicking in the Program Editor window, choose "Recall Last Submit" Under the "Run" Menu (or press F4).) When you run the program, the desired results should appear in the Output window. (If they don't, check the Log Window; there is probably an error.) If you run another program, the new results will continue to pile up in the Output window; the previous Output won't be automatically overwritten. This may get messy or confusing, so to clear the Output window at any time, you can click in the Output window and then choose "Clear All" under the "Edit" menu. You can save the program you've written by choosing the save option in the "File" menu. Having learned where to write the SAS code, how to run the programs, and where to look for the results, let's look at a sample SAS program. Note that when writing SAS code, you can include "comments", text that is not executed by SAS but is merely to help yourself or others understand what the code means. In SAS, lines which begin with an asterisk and end in a semicolon are comments. So are lines which begin with slash-asterisk and end with asterisk-slash. See the following program for examples: /* begin SAS program */ * Whether you type lowercase or uppercase doesn't matter. ; * SAS is not case-sensitive. ; DATA satscore; * The DATA command names the data set ; * The name should begin with a letter and be no more than 8 characters long ; * I give this data set the name "satscore" b/c the data are SAT scores for states; INPUT state $ sat1990 sat2000; /* The INPUT command names the variables (the columns) in the data set */ /* These names should also be 8 characters or less */ /* The variable "state" has a dollar sign after it */ /* This is because it is qualitative (non-numerical) */ /* Any qualitative variable needs a dollar sign */ /* after its name in the INPUT line */ * When the data are typed/copied into the program, the command "cards" tells SAS ; * that the next lines consist of data. ; * We could also use the command "lines" or "datalines" to do the same thing: ; cards; Alabama 1079 1114 Alaska 1015 1034 Arizona 1041 1044 Arkansas 1077 1117 California 1002 1015 Colorado 1067 1071 Connecticu 1002 1017 Delaware 1006 998 D.C. 950 980 Florida 988 998 Georgia 951 974 Hawaii 985 1007 Idaho 1066 1081 Illinois 1089 1154 Indiana 972 999 Iowa 1172 1189 Kansas 1129 1154 Kentucky 1089 1098 Louisiana 1088 1120 Maine 991 1004 Maryland 1008 1016 Massachuse 1001 1024 Michigan 1063 1126 Minnesota 1110 1175 Mississipp 1090 1111 Missouri 1089 1149 Montana 1082 1089 Nebraska 1121 1131 Nevada 1022 1027 NHampshire 1028 1039 NJersey 993 1011 NMexico 1100 1092 NewYork 985 1000 NCarolina 948 988 NDakota 1157 1197 Ohio 1048 1072 Oklahoma 1095 1123 Oregon 1024 1054 Pennsylvan 987 995 RIsland 986 1005 SCarolina 942 966 SDakota 1150 1175 Tennessee 1102 1116 Texas 979 993 Utah 1121 1139 Vermont 1000 1021 Virginia 997 1009 Washington 1024 1054 WestVA 1034 1037 Wisconsin 1111 1181 Wyoming 1072 1090 ; /* A COMMENT ABOUT SEMICOLONS */ * Note that just about every line of code ends with a semicolon in SAS ; * The exceptions are the lines of data ; * but there IS a single semicolon at the end of all the data ; * Be careful that your semicolons are all there ; * This is a very common (and easily correctable) cause of errors in SAS ; * If your program has an error, first see if you've left off any semicolons; /* How can we print these data into the Results Window? */ PROC PRINT DATA=satscore; TITLE "SAT Scores from 1990 and 2000 for the 50 States"; RUN; /* How can we make a scatterplot of these data in the Results Window? */ PROC SGPLOT DATA=satscore; SCATTER y=sat2000 x=sat1990; TITLE "Plot of SAT Scores from 1990 and 2000 for the 50 States"; RUN; /* The TITLE command gives the Output a nice title */ TITLE; /* The single TITLE; line cancels all previous titles for future output. */ /* The RUN command should appear at the end of this PRINT procedure */ /* or any other SAS procedure */ /* A missing RUN command is another common error -- be careful! */ /* end SAS program */ While you can print out the contents of the Output window directly from SAS, sometimes this is a waste of paper, since SAS isn't efficient in this way. A better way to print results is to first copy the Output from SAS and paste it into a word processing program such as Microsoft Word. (Use the "Courier New" font in Word if you do this.) Then print the Word document. You can also copy and paste into Word the graphs we obtain using PROC INSIGHT, as we will see on the first Homework set. This is the recommended way to print out graphs.