SAS: formats/informats/types. Their differences

gaussblurinc picture gaussblurinc · Apr 16, 2012 · Viewed 12.7k times · Source

another question about formats and informats:

formats are using for output (for show me and other user data in tables), so, i don't care about it, if i want read data from tables in programming way, yes?

but what is informat?

i have data step with code like this:

 data Out; 
       attrib __fromDate __ToDate informat=ddmmyy16. format=worddatx32.
              __name __country length = $10
       ;

 set InputTab;

 /*see Dates*/
 retain __fromDate .;
 retain __ToDate .; 

/*see Strings*/
 retain __name "";
 retain __country "";

 __fromDate=coalesce(__fromDate,fromDate);
 __ToDate=coalesce(__fromDate,fromDate);
 __name=coalescec(__name,name);
 __country=coalescec(__country,country);

run;     

Does this code work and what type have all these vars on each statement?

Am i right, that informat and type of var are similar?

And also, are dates (__ToDate, __FromDate ) have a numeric type? (their missing value is dot ., not quotes "")?

Thank you!

Answer

Robbie Liu picture Robbie Liu · Apr 16, 2012

In SAS, variables have two possible types: character or numeric.

Informat is similar but a little different. It controls how SAS read data from external data sources. There are three variants, numeric, character and date/time. Citing the code you provide here, informat=ddmmyy16. tells SAS to read input data in a date/time format. 16 is the width. There are many informat, conditioning on like length, decimals etc.

And also, are dates (__ToDate, __FromDate ) have a numeric type? (their missing value is dot ., not quotes "")?

In SAS, missing value of character type is given double quote "". For numeric type, it is dot .. Date/time is regarded as a numeric type.