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

data bank2;
infile datalines dsd;
input name $ rate;
datalines;
FirstCapital 0.0718
DirectBank 0.0721
VirtualDirect 0.0728
;
run;
proc print data = bank2;
run;

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

Your sample program is most of the solution.  However, by reading across from left to right and taking whatever is found in the data, the program has to decide how many characters to use to store NAME.  In that situation, the software automatically uses a length of 8, so values of NAME will be truncated.  To fix that, define NAME before the INPUT statement:

data bank2;
infile datalines dsd;
length name $ 15;
input name $ rate;
datalines;
FirstCapital 0.0718
DirectBank 0.0721
VirtualDirect 0.0728
;

Just select a length that makes sense for the data you need to read.

 

Also note, if some values of NAME contain an embedded blank such as "First Capital", you will need to take additional steps.

View solution in original post

4 REPLIES 4
jimbarbour
Meteorite | Level 14
I don't understand. What ate you asking?

If you are getting errors, please post your log.

Jim
tianerhu
Pyrite | Level 9
I want to make a SAS data set using datalines statement ,the data in the datalines as following:

FirstCapital 0.0718
DirectBank 0.0721
VirtualDirect 0.0728

the variable name is 'name' and 'rate' .
Astounding
PROC Star

Your sample program is most of the solution.  However, by reading across from left to right and taking whatever is found in the data, the program has to decide how many characters to use to store NAME.  In that situation, the software automatically uses a length of 8, so values of NAME will be truncated.  To fix that, define NAME before the INPUT statement:

data bank2;
infile datalines dsd;
length name $ 15;
input name $ rate;
datalines;
FirstCapital 0.0718
DirectBank 0.0721
VirtualDirect 0.0728
;

Just select a length that makes sense for the data you need to read.

 

Also note, if some values of NAME contain an embedded blank such as "First Capital", you will need to take additional steps.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 4 replies
  • 635 views
  • 1 like
  • 3 in conversation