Você está na página 1de 3

/**************************************************************************** *******/ /* Program Name: Assignment 02-SAS programming */ /* Date Created: Oct 2013 */ /* Author: Pedram Tolouei */ /* Purpose:

Generates file/dataset for home work No9 */ /* Inputs: C:\Users\Pedram\Desktop\Fall2013\PRG1 Data and Programs (New)\donation.dat */ /* ------------------------------------------------------------------------------ */ /* Macros: None */ /* */ /* ------------------------------------------------------------------------------ */ /* #2 Fileref for PDF output file*/ filename pdfout 'C:\Users\Pedram\Desktop\Fall2013\STAT604\HW9\hw9.pdf'; /* #3 creating a cleaned up jobs data set*/ libname pedram "C:\Users\Pedram\Desktop\Fall2013\STAT604\HW9"; /* 3a. Remove observations that have a missing State value. */ Data pedram.clean; set pedram.jobsdata; where State ne ''; /* 3b. Supply labels for all of the month variables */ label Aug2012= 'August 2012' Sept2012='September 2012' Oct2012='October 2012' Nov2012= 'November 2012' Dec2012='December 2012' Jan2013= 'January 2013' Feb2013='February 2013' Mar2013='March 2013' Apr2013= 'April 2013' May2013= 'May 2013' June2013='June 2013' July2013='July 2013' Aug2013= 'August 2013'; /* 3c. Creating a new variable labeled Report Date*/ Report_Date= '09/16/2013'; /* 3d. Creating a variable labeled Annual Change*/ Annual_Change=(aug2013-aug2012)/aug2012; format Annual_Change percent8.1; run; /*4 observations that have an annual change of 10 percent or more positive or negative. */ Data temp1; set pedram.clean; where Annual_Change>0.1 or Annual_Change<-0.1 and Annual_Change is not missing; keep Annual_Change State Industry Aug2013 Aug2012 Report_Date ; run; /*5 Create a data set having observations where the number of jobs in August 2013 is at least 1 less than the number of jobs in July 2013. */ Data temp2; set pedram.clean; where 1<July2013-Aug2013; keep Industry state Jan2013 Feb2013 Mar2013 Apr2013 May2013 June2013 July2013 Aug2013; run;

/*6. Create a temporary data set of service industries as indicated by the word services in the */ /*industry name. Remove observations that are missing the Annual Change value */ Data temp3; set pedram.clean; where Industry contains 'SERVICES' and Annual_Change is not missing; keep State Aug2012 Aug2013 Annual_Change Industry ; format Aug2012 Aug2013 comma12.; run; /*7. Create a temporary data set of the southwestern states of Arizona, California, Colorado, */ /*Nevada, New Mexico, Oklahoma, Texas, and Utah. Exclude the Government industry sector */ /*from this data set. Remove the 2012 months and the Report Date from this data set. */ Data temp4; set pedram.clean; where State in('Arizona','California','Colorado', 'Nevada','New Mexico','Oklahoma','Texas', 'Utah') and Industry ne 'GOVERNMENT'; drop Aug2012 Sept2012 Oct2012 Nov2012 Dec2012 Report_date; run; /*8. Open a PDF destination using the fileref created above. save paper, we do not want */ /*to automatically start a new page for each table printed.*/ ods pdf file=pdfout notoc startpage=no; /*9. Print the descriptor portion of the cleaned up jobs data set created in step 3. */ proc contents data=pedram.clean; run; /*10. Print the data portion of each of the temporary data sets created in steps 4 7. Ensure the */ /*variable labels are included in the output and that the variables on your output appear in the */ /*same order as the sample output posted on DoStat. Include or remove observation numbers */ /*from your output to match the output posted on DoStat. */ proc print data=work.temp1 noobs label; var Annual_Change State Industry Aug2013 Aug2012 Report_Date; run; proc print data=work.temp2 noobs label; var Industry state Jan2013 Feb2013 Mar2013 Apr2013 May2013 June2013 July2013 Aug2013; run; proc print data=work.temp3 label; var State Aug2012 Aug2013 Annual_Change Industry; run; proc print data=work.temp4 noobs label; var Industry State Jan2013 Feb2013 Mar2013 Apr2013 May2013 June2013 July2013 Aug2013 Annual_Change; run; In order to

ods pdf close; /*11. Convert the program and log to PDF files and submit them to WebAssign along with your SAS */ /*output.*/

Você também pode gostar