the data step:
data Financial;
infile 'C:\books\learning\Bank.txt';
input Subj $ 1-3 DOB $ 4-13 Gender $ 14 Balance 15-21;
run;
and 3.8 below follows on the data step for reading raw data from fixed columns:
Program 3.8: Demonstrating a FORMAT Statement
title "Listing of Financial";
proc print data=Financial;
format DOB mmddyy10.
Balance dollar11.2;
run;
produce error:
ERROR: You are trying to use the character format $ with the numeric variable Gender in data set
WORK.FINANCIAL
I appreciate your feedback
data Financial;
infile 'C:\books\learning\Bank.txt';
informat DOB mmddyy10.;
input Subj $ 1-3 DOB 4-13 Gender $ 14 Balance 15-21;
run;
Then try printing it and applying a format.
@DJ3 wrote:
the data step:
data Financial;
infile 'C:\books\learning\Bank.txt';
input Subj $ 1-3 DOB $ 4-13 Gender $ 14 Balance 15-21;
run;and 3.8 below follows on the data step for reading raw data from fixed columns:
Program 3.8: Demonstrating a FORMAT Statement
title "Listing of Financial";
proc print data=Financial;
format DOB mmddyy10.
Balance dollar11.2;
run;produce error:
ERROR: You are trying to use the character format $ with the numeric variable Gender in data set
WORK.FINANCIAL
I appreciate your feedback
I appreciate the feedback from all.
I introduce the DOB format in the input and run the code. it worked fine, no error:
data financial;
infile 'V:\Examples\learning\Bank.txt';
input subj $ 1 - 3
@4 DOB mmddyy10.
Gender $ 14
Balance 15 -21;
run;
proc print data=Financial;
format DOB mmddyy10.
Balance dollar11.2;
run;
this worked.
@DJ3 wrote:
the data step:
data Financial;
infile 'C:\books\learning\Bank.txt';
input Subj $ 1-3 DOB $ 4-13 Gender $ 14 Balance 15-21;
run;and 3.8 below follows on the data step for reading raw data from fixed columns:
Program 3.8: Demonstrating a FORMAT Statement
title "Listing of Financial";
proc print data=Financial;
format DOB mmddyy10.
Balance dollar11.2;
run;produce error:
ERROR: You are trying to use the character format $ with the numeric variable Gender in data set
WORK.FINANCIAL
I appreciate your feedback
Please post the full code and log in readable form.
The code you have posted won't create the error message, because you have no statement assigning a format to the variable "Gender".
data Financial;
infile 'C:\books\learning\Bank.txt';
informat DOB mmddyy10.;
input Subj $ 1-3 DOB 4-13 Gender $ 14 Balance 15-21;
run;
Then try printing it and applying a format.
@DJ3 wrote:
the data step:
data Financial;
infile 'C:\books\learning\Bank.txt';
input Subj $ 1-3 DOB $ 4-13 Gender $ 14 Balance 15-21;
run;and 3.8 below follows on the data step for reading raw data from fixed columns:
Program 3.8: Demonstrating a FORMAT Statement
title "Listing of Financial";
proc print data=Financial;
format DOB mmddyy10.
Balance dollar11.2;
run;produce error:
ERROR: You are trying to use the character format $ with the numeric variable Gender in data set
WORK.FINANCIAL
I appreciate your feedback
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.
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.