Lesson 3, Part 3: Informat vs. Format¶
INFORMATS vs. FORMATS¶
Memorize the following:
INFORMAT = How the raw data (e.g., nonstandard numeric data) is read into SAS
FORMAT = How the variable value is displayed
In [94]:
options nocenter nonumber nodate;
data _null_;
input amount: dollar8. date: mmddyy10.;
putlog "Original variables' values " amount= date= /;
putlog 'Formats added to the variables: ' amount= dollar8. date= mmddyy10. /;
putlog 'New formats added to the variables: ' amount= comma5. date= date9. /;
putlog 'Another New formats added to the variables: ' amount= comma7.2 date= worddate20. /;
datalines;
$1,250 01/15/2025
;
The SAS System 4194 ods listing close;ods html5 (id=saspy_internal) file=_tomods1 options(bitmap_mode='inline') device=svg style=HTMLBlue; 4194 ! ods graphics on / outputfmt=png; NOTE: Writing HTML5(SASPY_INTERNAL) Body file: _TOMODS1 4195 4196 options nocenter nonumber nodate; 4197 data _null_; 4198 input amount: dollar8. date: mmddyy10.; 4199 putlog "Original variables' values " amount= date= /; 4200 putlog 'Formats added to the variables: ' amount= dollar8. date= mmddyy10. /; 4201 putlog 'New formats added to the variables: ' amount= comma5. date= date9. /; 4202 putlog 'Another New formats added to the variables: ' amount= comma7.2 date= worddate20. /; 4203 datalines; Original variables' values amount=1250 date=23756 Formats added to the variables: amount=$1,250 date=01/15/2025 New formats added to the variables: amount=1,250 date=15JAN2025 Another New formats added to the variables: amount=1250.00 date=January 15, 2025 NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.00 seconds 4205 ; 4206 4207 4208 ods html5 (id=saspy_internal) close;ods listing; 4209 The SAS System 4210
In [90]:
options nocenter nonumber nodate;
data _null_;
input (c_amount c_date) ($);
n_amount = input(c_amount, dollar8.);
n_date = input(c_date, mmddyy10.);
putlog "Original character variables' values " c_amount= c_date= /;
putlog "Character-to-numeric variables' values " n_amount= n_date= /;
putlog "Formats added to the numeric variables' values " n_amount= comma5. n_date= worddate20. /;
datalines;
$1,250 01/15/2025
;
The SAS System 4019 ods listing close;ods html5 (id=saspy_internal) file=_tomods1 options(bitmap_mode='inline') device=svg style=HTMLBlue; 4019 ! ods graphics on / outputfmt=png; NOTE: Writing HTML5(SASPY_INTERNAL) Body file: _TOMODS1 4020 4021 options nocenter nonumber nodate; 4022 data _null_; 4023 input (c_amount c_date) ($); 4024 n_amount = input(c_amount, dollar8.); 4025 n_date = input(c_date, mmddyy10.); 4026 putlog "Original character variables' values " c_amount= c_date= /; 4027 putlog "Character-to-numeric variables' values " n_amount= n_date= /; 4028 putlog "Formats added to the numeric variables' values " n_amount= comma5. n_date= worddate20. /; 4029 datalines; Original character variables' values c_amount=$1,250 c_date=01/15/20 Character-to-numeric variables' values n_amount=1250 n_date=21929 Formats added to the numeric variables' values n_amount=1,250 n_date=January 15, 2020 NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.00 seconds 4031 ; 4032 4033 4034 ods html5 (id=saspy_internal) close;ods listing; 4035 The SAS System 4036
In [ ]: