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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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