SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Tal
Pyrite | Level 9 Tal
Pyrite | Level 9

hi guys

I want SAS to read in the following:

data one;

input name & :$20.  age;

cards;

Marry lee Jones 40

Arnold Jonson 45

;

but i get errors

What am i doing wrong here?

please help?

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

& says to keep reading until it sees two or more spaces.  So the 40 on the first line becomes part of the name. It then needs to go to the next line to read the age and cannot translate Arnold into a number. Hence the error message.

Add an extra space in front of the age on each row.

View solution in original post

4 REPLIES 4
Tom
Super User Tom
Super User

& says to keep reading until it sees two or more spaces.  So the 40 on the first line becomes part of the name. It then needs to go to the next line to read the age and cannot translate Arnold into a number. Hence the error message.

Add an extra space in front of the age on each row.

Tal
Pyrite | Level 9 Tal
Pyrite | Level 9

That was quick and sweet Smiley Happy

Thanks Tom

stat_sas
Ammonite | Level 13

Hi Tom,

Based on this discussion, I need to learn how can we refer variable names with spaces or dash - or dots (.)  betwen them in arrays?

e.g. NON BUYERS

Thanks,

Naeem

Tom
Super User Tom
Super User

Start a new thread and explain in more detail what you want.

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1046 views
  • 1 like
  • 3 in conversation