It is a little more complicated to obtain plots of two histograms on the same scale, because it depends on the device you are using to print. At home this is rather easy, and I am including instructions for doing this. In the PC Lab, you'll have to ask the SAS help desk what device you use and how to set yourself up for printing this graph. BASIC ANALYSIS OF THE NHANES DATA: WITHOUT PROC CAPABILITY (nhanshrt.sas) ----------------------------------------------------------- (1) I placed the data on my PC in the directory c:\sas (2) I called the data hanes.dat (3) I used windows95 to open SAS. This put the cursor in the program editor. (4) I typed the basic input data: options ls = 72; data nhanes1; input treatmen satfat; lsatfat = log(1+satfat); cards; (5) In the menu on top, I clicked on the "open" icon, two icons to the right of the running little man. (6) At the top of the resulting box, it asks me for a place to "look in". Since my data are in c:\sas\datasets, I clicked until I got there. (7) At the bottom, it asks for a "file name". It originally has the contents "*.sas", which I deleted and replaced by hanes.dat. (8) I then finished by clicking on the "open" bar. This updates my program by adding the data in. (9) I then saved everything by going to "file", hitting the "save as" key, and naming the program nhanes. This is thus saved as c:\sas\nhanshrt.sas. (10) From now on, I can makes changes to nhanes.sas and then save them by hitting the floppy disk icon. (11) Now I add to my program. Scroll to the end of the data, and type on a new line proc sort; by treatmen; proc univariate plot; var satfat lsatfat; by treatmen; run; (12) You now have a complete initial analysis of the NHANES data. (13) What I do is get out of SAS, then reenter it, go to the program editor window, click on "file", click on "open", open nhanshrt.sas, and then click on the running little man. The output file will open and I can click on print to print the output. BASIC ANALYSIS OF THE NHANES DATA: WITH PROC CAPABILITY (nhanrun.sas) ----------------------------------------------------------- (1) I placed the data on my PC in the directory c:\sas (2) I called the data hanes.dat (3) I used windows95 to open SAS. This put the cursor in the program editor. (4) I typed the basic input data: data nhanes1; input treatmen satfat; lsatfat = log(1+satfat); cards; (5) In the menu on top, I clicked on the "open" icon, two icons to the right of the running little man. (6) At the top of the resulting box, it asks me for a place to "look in". Since my data are in c:\sas\datasets, I clicked until I got there. (7) At the bottom, it asks for a "file name". It originally has the contents "*.sas", which I deleted and replaced by hanes.dat. (8) I then finished by clicking on the "open" bar. This updates my program by adding the data in. (9) I then saved everything by going to "file", hitting the "save as" key, and naming the program nhanes. This is thus saved as c:\sas\nhanshrt.sas. (10) From now on, I can makes changes to nhanes.sas and then save them by hitting the floppy disk icon. (11) Now I add to my program. Scroll to the end of the data, and type on a new line proc sort; by treatmen; proc capability graphics; comphistogram satfat / class = treatmen; title NHANES Data (1=disease); proc capability graphics; comphistogram lsatfat / class = treatmen; title NHANES Data (1=disease); proc univariate plot; var satfat lsatfat; by treatmen; run; (12) Save this again by hitting the floppy disk icon. (13) Hit the little running man to run the program. A graphics window will open up. At the bottom it says "Press forward to see next graph". Click on the black down arrow key at the top of the screen and the next graph will show up, etc. (14) You should have an output window. Click on the printer to print your results. (15) To get the pretty comparative histograms, do the following steps: (a) Click on "Window" at the top and scroll down to "graph..." and release the mouse key. (b) Use the black arrow keys at the top to scroll between pretty graphs. (c) Everytime you see one you like, click on the printer icon. It asks you something about device. Click on help, and scroll to "Printer" and click on it. Then slect your printer from the menu, click on that and then select "OK". Do this for each pretty plot you want. My printer by the way is hpjl100, a laser jet series 2 printing 100 dpi. (16) You now have a complete initial analysis of the NHANES data. Here is the program that ran all these analyses. If you have a problem like this in homework, just rename all the variables and use any editor you want to replace the data. Then when you get into sas, go to "file", then "open" and open the file which has all the data and the program, and run the little running man icon. *************************************************************************** Initial Data Analysis of NHANES Data With comparative histograms *************************************************************************** options ls = 72; data nhanes1; input treatmen satfat; lsatfat = log(satfat); cards; DATA HERE proc sort; by treatmen; proc capability graphics; comphistogram satfat / class = treatmen; title NHANES Data (1=disease); proc capability graphics; comphistogram lsatfat / class = treatmen; title NHANES Data (1=disease); proc univariate plot; var satfat lsatfat; by treatmen; run;