data bank2;
infile datalines dsd;
input name $ rate;
datalines;
FirstCapital 0.0718
DirectBank 0.0721
VirtualDirect 0.0728
;
run;
proc print data = bank2;
run;
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.
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 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.