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
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.