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

The objective here is to output a raw data file. I know that Put and File are used to write raw data file. I am not sure here there is INFILE which is used to read data, cards, missover and  text and lrecl?

 

data _null_;
infile cards missover length=l;
length text $ 50;
input text $varying50. l;
file aprdata pad lrecl=80;
put text;
datalines;
Akron 04/05/99 04/09/99 175.00 298.45
Brown 04/12/99 05/01/99 125.00 326.78
Carnes 04/27/99 04/29/99 125.00 174.24
Denison 04/11/99 04/12/99 175.00 87.41
Fields 04/15/99 04/22/99 175.00 378.96
Jamison 04/16/99 04/23/99 125.00 346.28
;

1 ACCEPTED SOLUTION

Accepted Solutions
mohamed_zaki
Barite | Level 11

First let us make sure that you know that:

DATALINES (or CARDS) Informs SAS that the input data resides inside the code (in-stream data) and immediately follows the DATALINES (or CARDS) statement.

 

Senond thing is:

You may use the INFILE statement with the DATALINES (or CARDS) to process instream data and still utilize other INFILE options.

 

And here in your example INFILE options missover and  length= are utilized in reading the in-stream data. Both you can read about here INFILE Statement

 

Finally, based on previous posts by you i can understand that you are preparing for the base certification. And what i hope is you do not be confused by this sample data code with the book. This code generate data used in the book and you are not asked to know every thing in that code at least for the base exam. You are not going to get any questions out of the exam scopes or reading difficult raw data not covered in the certification book.

View solution in original post

6 REPLIES 6
mohamed_zaki
Barite | Level 11

First let us make sure that you know that:

DATALINES (or CARDS) Informs SAS that the input data resides inside the code (in-stream data) and immediately follows the DATALINES (or CARDS) statement.

 

Senond thing is:

You may use the INFILE statement with the DATALINES (or CARDS) to process instream data and still utilize other INFILE options.

 

And here in your example INFILE options missover and  length= are utilized in reading the in-stream data. Both you can read about here INFILE Statement

 

Finally, based on previous posts by you i can understand that you are preparing for the base certification. And what i hope is you do not be confused by this sample data code with the book. This code generate data used in the book and you are not asked to know every thing in that code at least for the base exam. You are not going to get any questions out of the exam scopes or reading difficult raw data not covered in the certification book.

ablo
Fluorite | Level 6

Hi Mohammed, 

Can you tell me why they have 'text' there?

mohamed_zaki
Barite | Level 11

"text" is just a variable name, you can replaced by any valid name...

ablo
Fluorite | Level 6

ok, but what does it do to the put statement? I know that put is the same as input but for writing data to an external file. Usually we have several variable for the number of column in the put statement but here we have "text" only.

mohamed_zaki
Barite | Level 11

because as you can see. They red each line in the data lines as one string variable.

To get a better idea run the code without puting to file 

data new;
infile cards missover length=l;
length text $ 50;
input text $varying50. l;

datalines;
Akron 04/05/99 04/09/99 175.00 298.45
Brown 04/12/99 05/01/99 125.00 326.78
Carnes 04/27/99 04/29/99 125.00 174.24
Denison 04/11/99 04/12/99 175.00 87.41
Fields 04/15/99 04/22/99 175.00 378.96
Jamison 04/16/99 04/23/99 125.00 346.28
;
ablo
Fluorite | Level 6
I understand
Thanks Mohamed.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 6 replies
  • 1843 views
  • 2 likes
  • 2 in conversation