DATA Step, Macro, Functions and more

Need help inputting data with datalines

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 124
Accepted Solution

Need help inputting data with datalines

Greetings.  I am trying to load some addresses into one column of a dataset by using a datalines statement.  When I run the below, only about half of the addresses are being loaded.  I have tried cards, and messing with the format to no avail.  I think it must be something simple, but I can't get it.  One other thing, now I cannot even paste into this post, so the code is attached.  I apologize for the inconvenience.  Thank you.

Greg


Attachment

Accepted Solutions
Solution
‎10-29-2012 10:48 AM
PROC Star
Posts: 7,363

Re: Need help inputting data with datalines

Add an ampersand.  i.e.,

input Address & $100.;

View solution in original post


All Replies
Solution
‎10-29-2012 10:48 AM
PROC Star
Posts: 7,363

Re: Need help inputting data with datalines

Add an ampersand.  i.e.,

input Address & $100.;

Frequent Contributor
Posts: 124

Re: Need help inputting data with datalines

Thank you Arthur, that worked like a charm.

Greg

Super User
Super User
Posts: 6,500

Re: Need help inputting data with datalines

The & will allow SAS to read variable length data, but it will truncate when it sees two adjacent spaces.

You can add an INFILE statement so that you can use the TRUNCOVER option.

data Addresses;

infile datalines truncover;

input Address $100.;

datalines;

Or you could use the _INFILE_ automatic variable.

data Addresses;

length address $100;

input;

address=_infile_;

datalines;

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 179 views
  • 0 likes
  • 3 in conversation