I tried the below code
But i am not getting the. result.I need some help.Is there any other method.help me out please
DATA Sara2013;
INFORMAT Date YYMMDD10. Time $5. ;
FORMAT Date YYMMDD10. Time $5. ;
INFILE 'C:\nav\2013_Satisfaction_Survey_Sara (4).txt'
LRECL=32767 dsd dlm='' truncover firstobs=2;
INPUT @1 Date: YYMMDD10. @12 Time : $5.
@18 Interviewer :$4. @23 Age :$2. @26 Gender :$1. @28 Address: &$18. @48 FirstTime :$6. @52 ComeAgain :$5. WhyNot: $11. (Sat1-Sat8)(:$3.) Comments :$50.;
;
RUN;
The following worked for me:
DATA Sara2013;
INFILE 'C:\temp\2013_Satisfaction_Survey_Sara (2).txt'
LRECL=32767 termstr=LF truncover firstobs=2;
informat date yymmdd10.;
informat time $5.;
informat interviewer $4.;
informat age $2.;
informat gender $1.;
informat address $18.;
informat FirstTime $3.;
informat ComeAgain $3.;
informat WhyNot $11.;
informat Sat1-Sat7 $3.;
informat Sat8 $2.;
informat Comments $50.;
FORMAT Date YYMMDD10. Time $5. ;
INPUT @1 Date Time 12-16
Interviewer 18-21 Age 23-24 Gender 26-26 Address 28-46
FirstTime 48-50 ComeAgain 52-54 WhyNot 56-66
Sat1 68-70 Sat2 72-74 Sat3 76-78 Sat4 80-82
Sat5 84-86 Sat6 88-90 Sat7 92-94 Sat8 96-97 Comments 98-147;
;
RUN;
The following worked for me:
DATA Sara2013;
INFILE 'C:\temp\2013_Satisfaction_Survey_Sara (2).txt'
LRECL=32767 termstr=LF truncover firstobs=2;
informat date yymmdd10.;
informat time $5.;
informat interviewer $4.;
informat age $2.;
informat gender $1.;
informat address $18.;
informat FirstTime $3.;
informat ComeAgain $3.;
informat WhyNot $11.;
informat Sat1-Sat7 $3.;
informat Sat8 $2.;
informat Comments $50.;
FORMAT Date YYMMDD10. Time $5. ;
INPUT @1 Date Time 12-16
Interviewer 18-21 Age 23-24 Gender 26-26 Address 28-46
FirstTime 48-50 ComeAgain 52-54 WhyNot 56-66
Sat1 68-70 Sat2 72-74 Sat3 76-78 Sat4 80-82
Sat5 84-86 Sat6 88-90 Sat7 92-94 Sat8 96-97 Comments 98-147;
;
RUN;
Thanks Arthur.But,what is trmstr='lF' option and why individually writing of informat statement .cant we mention with a colon modifier :
You probably need to add the TRUNCOVER option to the INFILE statement since some of the lines appear shorter than others.
Also you need to add the FIRSTOBS=2 option to get it to skip the header line in the file.
termstr=LF is to indicate that your records end with '10'x (line feed) character, rather that the combination of a CR and a line feed.
While I don't know how common it is, I have always liked defining informats rather than specifying them in the input statement and using colons. Obviously, you could try alternative approaches, but the one I suggested appears to correctly read your file.
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!
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.