SAS Chapter 5

10 Questions | Attempts: 559
Share

SettingsSettingsSettings
SAS Chapter 5 - Quiz

Practice for the basic SAS certification exam.


Questions and Answers
  • 1. 

    Which SAS statement associates the fileref Crime with the raw data file C:\States\Data\Crime?

    • A.

      Filename crime 'C:\States\Data\Crime';

    • B.

      Filename crime C:\States\Data\Crime;

    • C.

      Fileref crime 'C:\States\Data\Crime';

    • D.

      Filename 'C:\States\Data\Crime' crime;

    Correct Answer
    A. Filename crime 'C:\States\Data\Crime';
    Explanation
    Before you can read your raw data, you must reference the raw data file by creating a fileref. You assign a fileref by using a FILENAME statement in the same way that you assign a libref by using a LIBNAME statement.

    Rate this question:

  • 2. 

    Filerefs remain in effect until...

    • A.

      You change them

    • B.

      You cancel them

    • C.

      You end your SAS session.

    • D.

      All of the above

    Correct Answer
    D. All of the above
    Explanation
    Like LIBNAME statements, FILENAME statements are global; they remain in effect until you change them, cancel them, or end your SAS session.

    Rate this question:

  • 3. 

    Which statement identifies the name of a raw data file to be read with the fileref Products and specifies that the DATA step read only records 1-15?

    • A.

      Infile products obs 15;

    • B.

      Infile products obs=15;

    • C.

      Input products obs=15;

    • D.

      Input products 1-15;

    Correct Answer
    B. Infile products obs=15;
    Explanation
    You use an INFILE statement to specify the raw data file to be read. You can specify a fileref or an actual filename (in quotation marks). The OBS=option in the INFILE statement enables you to process only records 1 through n.

    Rate this question:

  • 4. 

    Which of the following programs correctly writes the observations from the data set below to a raw data file?

    • A.

      Data_null_;      set work.patients;      infile 'c:\clinic\patients\referrals.dat';      input id 1-4 sex 6 age 8-9 height 11-12           weight 14-16 pulse 18-20; run;

    • B.

      Data referrals.dat;      set work.patients;      input id 1-4 sex 6 age 8-9 height 11-12           weight 14-16 pulse 18-20; run;

    • C.

      Data _null_;      set work.patients;      file c:\clinic\patients\referrals.dat;      put id 1-4 sex 6 age 8-9 height 11-12           weight 14-16 pulse 18-20; run;

    • D.

      Data _null_;      set work.patients;      file 'c:\clinic\patients\referrals.dat';      put id 1-4 sex 6 age 8-9 height 11-12           weight 14-16 pulse 18-20; run;

    Correct Answer
    D. Data _null_;      set work.patients;      file 'c:\clinic\patients\referrals.dat';      put id 1-4 sex 6 age 8-9 height 11-12           weight 14-16 pulse 18-20; run;
    Explanation
    The keyword _NULL_ in the DATA statement enables you to use the power of the DATA step without actually creating a SAS data set. You use the FILE and PUT statements to write out the observations from a SAS data set to a raw data file. The FILE statement specifies the raw data file and the PUT statement descrives the lines to write to the raw data file. The filename and location specified in the FILE statement must be enclosed in quotation marks.

    Rate this question:

  • 5. 

    Which raw data file can be read using column input?

    • A.
    • B.
    • C.
    • D.

      All of the above

    Correct Answer
    B.
    Explanation
    Column input is appropriate only in some situations. When you use column input, your data must be standard character or numeric values, and they must be in fixed fields. That is, values for a particular variable must be in the same location in all records.

    Rate this question:

  • 6. 

    Which program creates the output shown below?

    • A.

      Data work.salesrep;      infile empdata;      input ID $ 1-4 LastName $ 6-12           FirstName $ 14-18 City  $ 20-29; run; proc print data=work.salesrep; run;

    • B.

      Data work.salesrep;      infile empdata;      input ID $ 1-4 Name $ 6-12           FirstName $ 14-18 City $ 20-29; run; proc print data=work.salesrep; run;

    • C.

      Data work.salesrep;      infile empdata;      input ID $ 1-4 name1 $ 6-12           name2 $ 14-18 City $ 20-29; run; proc print data=work.salesrep; run;

    • D.

      All of the above

    Correct Answer
    A. Data work.salesrep;      infile empdata;      input ID $ 1-4 LastName $ 6-12           FirstName $ 14-18 City  $ 20-29; run; proc print data=work.salesrep; run;
    Explanation
    The INPUT statement creates a variable using the name that you assign to each field. Therefore, when you write an INPUT statement, you need to specify the variable names exactly as you want them to appear in the SAS data set.

    Rate this question:

  • 7. 

    Which statement correctly reads the fields in the following order: Stock Number, Price Item, Finish, Style?

    • A.

      Input StockNumber $ 1-3 Finish $ 5-9 Style $ 11-18      Item $ 20-24 Price 27-32;

    • B.

      Input StockNumber $ 1-3 Price 27-32      Item $ 20-24 Finish $ 5-9 Style $ 11-18;

    • C.

      Input $ StockNumber 1-3 Price 27-32 $      Item 20-24 $ Finish 5 9 $ Style 11-18;

    • D.

      Input StockNumber $ 1-3 Price $ 27-32      Item $ 20-24 Finish $ 5-9 Style $ 11-18;

    Correct Answer
    A. Input StockNumber $ 1-3 Finish $ 5-9 Style $ 11-18      Item $ 20-24 Price 27-32;
    Explanation
    You can use column input to read fields in any order. You must specify the variable name to be created, identify character values with a $, and name the correct starting column and ending column for each field.

    Rate this question:

  • 8. 

    Which statement correctly re-defines the values of the variable Income as 100 percent higher?

    • A.

      Income=income*1.00;

    • B.

      Income=income+(income*2.00);

    • C.

      Income=income*2;

    • D.

      Income=*2;

    Correct Answer
    C. Income=income*2;
    Explanation
    To re-define the values of the variable Income in an assignment statement, you specify the variable name on the left side of the equal sign and an appropriate expression including the variable name on the right side of the equal sign.

    Rate this question:

  • 9. 

    Which program correctly reads instream data;

    • A.

      Data finance.newloan;      input datalines;      if country='JAPAN';      MonthAvg=amount/12; 1998 US     CARS       194324.12 1998 US     TRUCKS     142290.30 1998 CANADA CARS        10483.44 1998 CANADA TRUCKS      93543.64 1998 MEXICO CARS        22500.57 1998 MEXICO TRUCKS      10098.88 1998 JAPAN  CARS        15066.43 1998 JAPAN  TRUCKS      40700.34 ;

    • B.

      Data finance.newloan;      input Year 1-4 Country $ 6-11            Vehicle $ 13-18 Amount 20-28;      if country='JAPAN';      MonthAvg=amount/12;      datalines; run;

    • C.

      Data finance.newloan;      input Year 1-4 Country 6-11            Vehicle 13-18 Amount 20-28;      if country='JAPAN';      MonthAvg=amount/12;      datalines; 1998 US     CARS       194324.12 1998 US     TRUCKS     142290.30 1998 CANADA CARS        10483.44 1998 CANADA TRUCKS      93543.64 1998 MEXICO CARS        22500.57 1998 MEXICO TRUCKS      10098.88 1998 JAPAN  CARS        15066.43 1998 JAPAN  TRUCKS      40700.34 ;

    • D.

      Data finance.newloan;      input Year 1-4 Country $ 6-11            Vehicle $ 13-18 Amount 20-28;      if country='JAPAN';      MonthAvg=amount/12;      datalines; 1998 US     CARS       194324.12 1998 US     TRUCKS     142290.30 1998 CANADA CARS        10483.44 1998 CANADA TRUCKS      93543.64 1998 MEXICO CARS        22500.57 1998 MEXICO TRUCKS      10098.88 1998 JAPAN  CARS        15066.43 1998 JAPAN  TRUCKS      40700.34 ;

    Correct Answer
    D. Data finance.newloan;      input Year 1-4 Country $ 6-11            Vehicle $ 13-18 Amount 20-28;      if country='JAPAN';      MonthAvg=amount/12;      datalines; 1998 US     CARS       194324.12 1998 US     TRUCKS     142290.30 1998 CANADA CARS        10483.44 1998 CANADA TRUCKS      93543.64 1998 MEXICO CARS        22500.57 1998 MEXICO TRUCKS      10098.88 1998 JAPAN  CARS        15066.43 1998 JAPAN  TRUCKS      40700.34 ;
    Explanation
    To read instream data, you specify a DATALINES statement and data lines, followed by a null statement (single semicolon) to indicate the end of the input data. Program a contains no DATALINES statement, and the INPUT statement doesn't specify the fields to read. Program b contains no data lines, and the INPUT statement in program c doesn't specify the necessary dollar signs for the character variables Country and Vehicle.

    Rate this question:

  • 10. 

    Which SAS statement subsets the raw data shown below so that only the observations in which Sex (in the second field) has a value of F are processed?

    • A.

      If sex=f;

    • B.

      If sex=F;

    • C.

      If sex='F';

    • D.

      A or b

    Correct Answer
    C. If sex='F';
    Explanation
    To subset data, you can sue a subsetting IF statement in any DATA step to process only those observations that meet a specified condition. Because Sex is a character variable, the value F must be enclosed in quotation marks and must be in the same case as the data set.

    Rate this question:

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 19, 2022
    Quiz Edited by
    ProProfs Editorial Team
  • Jan 17, 2013
    Quiz Created by
    Moxleyv

Related Topics

Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.