BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
chaitanya
Calcite | Level 5

data samp ;

input id date :ddmmyy10. age$ 2.;

cards;

102 12/11/198312

103 12/11/198914

;

run;

whenever i place colon modifier before a informat, it is reading a column larger than specified width in character variables and more than that in numeric... .please clarify how sas intrepets colon modifier..

1 ACCEPTED SOLUTION

Accepted Solutions
data_null__
Jade | Level 19

This is the same only different. Smiley Happy  SAS is ignoring the width specification on the numeric informat.  If you want to read the data properly use formatted input for both date and age.  Remove the colon.

29         data _null_;
30            infile cards column=col;
31            input id date :ddmmyy10. @;
32            put date=date. col=;
33            input age$ 2.;
34            put age= col=;
35            list;
36         cards;

NOTE:
Invalid data for date in line 37 5-16.
date=
. col=18
age=  col=
20
RULE:      ----+----
1----+----2----+----
37         102 12/11/198312
col=
20 id=102 date=. age=  _ERROR_=1 _N_=1
NOTE: Invalid data for date in line
38 5-16.
date=
. col=18
age=  col=
20
38         103 12/11/198914
col=
20 id=103 date=. age=  _ERROR_=1 _N_=2

View solution in original post

3 REPLIES 3
data_null__
Jade | Level 19

This is the same only different. Smiley Happy  SAS is ignoring the width specification on the numeric informat.  If you want to read the data properly use formatted input for both date and age.  Remove the colon.

29         data _null_;
30            infile cards column=col;
31            input id date :ddmmyy10. @;
32            put date=date. col=;
33            input age$ 2.;
34            put age= col=;
35            list;
36         cards;

NOTE:
Invalid data for date in line 37 5-16.
date=
. col=18
age=  col=
20
RULE:      ----+----
1----+----2----+----
37         102 12/11/198312
col=
20 id=102 date=. age=  _ERROR_=1 _N_=1
NOTE: Invalid data for date in line
38 5-16.
date=
. col=18
age=  col=
20
38         103 12/11/198914
col=
20 id=103 date=. age=  _ERROR_=1 _N_=2
chaitanya
Calcite | Level 5

Thanks for clarifying me....i have just one more doubt.....u said that first it reads the data till the delimiter then truncates it...will it read the data into PDV  and truncate afterwards? how the processing happens?

data_null__
Jade | Level 19

In the other example there is truncation because $10 defines the length of the otherwise undeclared character variable.  The input statement with :$10. reads until the delimiter is found with is demonstrated by the COLUMN position.  Truncation occurs when the character string is stored or written to the PDV (I suppose is a good enough way to describe it).

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 3 replies
  • 1160 views
  • 4 likes
  • 2 in conversation