DATA Step, Macro, Functions and more

raw date file

Reply
Occasional Contributor
Posts: 14

raw date file

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? I don,t understant because is 3

Super User
Posts: 17,824

Re: raw date file

The trick to understanding code is to comment each line.

Ones you don't understand will stand out.

 

Is there a specific piece of the code you're not understanding?

 

 

Super User
Posts: 10,500

Re: raw date file

When there are explicit OUTPUT statements data is only written to the data set when the Output is executed. The Output in the example is only executed when the condition :

if from_co='FRANCE' or from_co='SAFRICA'

is true.

So when the from country is FRANCE or SAFRICA is the only time you get results.

Ask a Question
Discussion stats
  • 2 replies
  • 140 views
  • 0 likes
  • 3 in conversation