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).

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

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