Do not use formatted input to read a delimited list, instead use list mode. Read the manual on the INPUT statement and it will explain the different input styles.
Define your variables before you use them in other statements. That includes before you use them in FORMAT, INFORMAT and INPUT statements. Then you are sure that your variables will be defined as you want them. It also makes it easier to use list mode input style since you do not have to worry about adding informats or column locations to the INPUT to help SAS guess how you wanted the variable defined.
data employee;
infile "myfile.txt" dlm="," dsd truncover;
length id 8 gender $1 salary birthdate hiredate termdate 8
maritalstat numdependents promostatus $1
;
input id -- promostatus ;
informat salary dollar7. birthdate hiredate termdate mmddyy10.;
format salary dollar7. birthdate hiredate termdate mmddyy10.;
run;
Note is does not matter where you put the FORMAT and INFORMAT statements as those are attributes of the variables that are set when the data step is compiled and not when it executes. (But note that if do put them BEFORE you have defined the variables via a LENGTH, ATTRIB or setting an existing dataset then SAS will add the variables to the dataset based on the format you have attached since they will be the first place you have used the variable. And it will impact the order that the variables are in the dataset.)
... View more