BookmarkSubscribeRSS Feed
beatraca
Fluorite | Level 6
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

2 REPLIES 2
Reeza
Super User

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?

 

 

ballardw
Super User

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.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1135 views
  • 0 likes
  • 3 in conversation