M2 Workshop STAT674

Execute the data step below to set up the data set for this workshop;
* Be sure the file m2_cars.dat is stored in the appropriate location
  on your computer to be accessed by SAS Studio;
*magic string;
;*’;*”;*/;
data work.carsales_indata;
    infile “/…/m2_cars.dat”;
    input manufacturer $9. loc $13. car_type $6. num_sold;
run;
   * Use the menu options at the left to view the SAS Library WORK containing
     the data set work.carsales_indata;
******************************************************************************;
**** Q1                ;
******************************************************************************;
* —Q1a – Use the proper PROC to see the variables contained in the dataset above.  List them below;
/*answer:



*/

* —Q1b – modify the code above to read only the first 5 observations in the raw data file.
           Be sure to change the name of the data set so that it does not overwrite the dataset created earlier;


* —Q1c – Check the log and print the data set to verify the data set was read properly;



* —Q1d – Modify the code again to read observations starting with record 7 in the file.
              Be sure to change the name of the data set so that it does not overwrite the datasets already created.
           Check the log and print the data set to verify the data set was read properly;



* —Q1e;
   * create a folder “m2” on SAS Studio, and create a libname to point to your m2 folder;
libname cars “/…/m2”;

** What do these statements below do?;
data cars.x;
x=1;
run;
/*answer:

*/


******************************************************************************;
*QUESTION 2;
******************************************************************************;
data cars.carsales;
   set work.carsales_indata;
   ds = ‘cars.carsales’;
   label loc =  ‘loc’;
   label manufacturer = ‘manufacturer’;
   label car_type = ‘Car Type’;
   label num_sold = ‘Number Sold’;
run;
* —Q2a;
   * What is the result of the data step above?
   * How many variables should the data set cars.carsales contain?;

* —Q2b;
proc print data=work.carsales_indata;
title ‘work.carsales_indata’;
run; 
   * How many variables does the data set work.carsales_indata actually contain?;

* —Q2c;
   * Run the proc print statement below;
proc print data=cars.carsales;
title ‘cars.carsales’;
run;
   * Which variables are in the data set? Are they what you expected?;


* —Q2d;
   * What is the difference, if any, between the printed output in Q2b and Q2c?;

* —Q2e;
   * Using proc contents to view the descriptor portion for cars.carsales and work.carsales_indata.
     What differences does this information reveal between the two data sets?;





**********************************************************************************;
*Q3;
**********************************************************************************;
* The file m2_cancer.txt contains three variables giving the rank, type of cancer
  and the incidence rate per 100,000 people.
  Use the variable names rank, site and rate, respectively;
* —Q3a.;
* Open the raw data file in a text editor, such as NotePad, TextEdit;
* How many variables and observations does the data file contain?;

* Are there any missing data values in the data file?;

* —Q3b;
* Write the code to create a SAS data set called cancer containing the contents of
  the raw data file m2_cancer.txt;

* —Q3c;
     * Write the code to display the descriptor portion of the dataset;


**************************************************************************;
****Q4;
**************************************************************************;

* For each part (a-d), do the following;
*   1. Update the path in the INFILE statement to reflect the location of your m2_cancer.txt file;
*    2. Run each section of code and check the log file;
*   3. If any errors occur,
           a. write a comment in the SAS program indicating the error reported in the log
           b. Briefly describe the cause of the error;
*     c. Modify the code to correct these errors;
*   4. If a data set is created by the data step provided,
           a. add code to print contents of the data file;
*     b. Is the information presented here consistent with the raw data file and the SAS code used to read the data set?;

* —Q4a;
data q4_a;
   infile ‘/…/m2_cancer.txt’;
   input rank 1-2 #_site $ 5-17 rate 19-23;
run;

********;
* —Q4b;
data q4_b;
   infile ‘/…/m2_cancer.txt’;
   input rank 1-2 site 5-17 rate 19-23;
run;
********;
* —Q4c;
data q4_c;
   infile ‘/…/m2_cancer.txt’;
   input rank 1-2 site $ 5-17 rate 19-23;
run;
********;
* —Q4d;
data q4_d;
   infile ‘/…/m2_cancer.txt’;
   input rank 1-2 $ site $ 5-17 rate 19-23;
run;

 

Click here to order similar paper @Udessaywriters.com.100% Original.Written from scratch by professional writers.

You May Also Like

About the Author: admin