SAS Base Certification – Practice Exam 4

Question 4: A raw data file is listed below:

1---+----10---+----20---+---
FRANCE,INDIA,10MAR2004
ITALY,USA,10/20/2004
SAFRICA,FRANCE,17JUN2004
AMERICA,FRANCE,12/31/2004
FRANCE,USA,20JAN2004
ITALY,USA,08/19/2004

The following SAS program is submitted using this file as input:

1
2
3
4
5
6
7
8
data work.flights;
   infile 'file-specification' dsd;
   input from_co $ @;
      if from_co='FRANCE' or from_co='SAFRICA' then do;
         input to_country $ flightdate : date9.;
         output;
      end;
run;

How many observations does the Work.Flights data set contain?

Options:

a.	0 
b.	3 
c.	5 
d.	6 

*This blog is not affiliated with SAS or the SAS Institute. All answer logs, data sets, output, and commentary are provided by this blog.

Correct Answer

Incorrect Answer

Click to see Answer Explanation below

thanks for your support

4 Comments

    A M Feb 18, 2015

    Hello,

    So I referenced this problem below and saw these problems were similar:

    data work.condo_ranch;
    infile ‘file-specification’ dsd;
    input style $ @;
    if style = ‘CONDO’ or style = ‘RANCH’ then
    input sqfeet bedrooms baths street $ price : dollar10.;
    run;

    The primary difference is the “DO”. Why/How does the “DO” in this code change the results?

    Reply
      igor Feb 23, 2015

      i believe primary difference is “Output” statement.

      Reply
      KCor Aug 05, 2015

      It does have to do with the OUTPUT statement.

      There is always an implicit OUTPUT statement right before run. If you insert an explicit OUTPUT statement anywhere else in the DATA step, then the implicit OUTPUT statement is removed.

      With its placement in the DO loop, it is outputting observations every time from_co=’FRANCE’ or from_co=’SAFRICA’ and ignoring all others, which is thee times.

      Reply
    Igor Mar 25, 2015

    update: primary difference is ; after then do

    Reply

Leave a Comment

Please keep in mind that comments are moderated and rel="nofollow" is in use. So, please do not use a spammy keyword or a domain as your name, or it will be deleted. Let us have a personal and meaningful conversation instead.