Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does a colon do in an input statement?

Tags:

sas

I found the following codes on SAS website, but couldn't understand what is the function of ":" here after input statement.

data recessions;                                                                                                                        
   input startdate :date7. enddate :date7.;                                                                                             
   format startdate enddate date7.;                                                                                                     
   datalines;                                                                                                                           
01Mar01  01Nov01                                                                                                                        
01Dec07  01Jun09                                                                                                                        
;                                                                                                                                       
run;  
like image 579
Yang Di Avatar asked Mar 15 '23 06:03

Yang Di


1 Answers

In list input, normally you are not allowed to supply an informat in the input statement; it is expected to be in an informat statement.

data recessions;
  informat startdate enddate date7.;
  format startdate enddate date7.;
  input startdate enddate;
datalines;
01MAR01 01NOV01
01DEC07 01JUN09
;
run;

However, a colon turns it into modified list input, which allows for the specification of an informat directly in the input statement.

Without that colon, SAS would interpret the informat to mean you wanted formatted input, which does not work (well) with delimited data like you have in those datalines.

like image 132
Joe Avatar answered Apr 29 '23 20:04

Joe