问题
Hi I am trying to import a tab delimited file in SAS that looks like this,
Names Points
Sumit1 10
Sumit2 20
SUmit4 30
SUmit5 85
SUmit6 90
SUmit7 39
hfgö®q-±òSÀ®téîÓVU«‘îj'n5E•d÷Yb#­AK$®SŽ†ÿ-ÍKÕw¿óå0"¤h—t0Ld 89
SUmit8 48
SUmit9 70
SUmit10 20
SUmit11 90
The first row represents column names.
I am using the following code to import the file,
data names;
infile "C:xxxxxxxx\names.txt"
delimiter='09'x MISSOVER DSD lrecl=32767 firstobs=2;
informat names $150.;
informat Points best32.;
format names $150.;
format Points best12.;
input names $
Points;
run;
and the sas data set after import looks like the following:
Names Points
Sumit1 10
Sumit2 20
SUmit4 30
SUmit5 85
SUmit6 90
SUmit7 39
hfgö®q-±òSÀ®téîÓVU«‘îj'n5E•d÷Yb#­AK$®SŽ†ÿ-ÍKÕw¿óå0"¤h—t0Ld .
So basically all the rows are not getting imported in sas and it stops at row 7 because of the presence of some unusual characters (I don't know what what this characters are called).
There are 1000 files like this that I need to import. So I am using a macro to import the files. Can somebody please help me how can I import this type of files in SAS.
回答1:
Try this code....
DATA names;
LENGTH Names $ 91 Points 8 ;
FORMAT Names $CHAR91. Points BEST2. ;
INFORMAT Names $CHAR91. Points BEST2. ;
INFILE 'C:xxxxxxxx\names.txt'
LRECL=32767 ENCODING="LATIN1" TERMSTR=CRLF DLM='7F'x MISSOVER DSD ;
INPUT Names : $CHAR91. Points : ?? BEST2. ;
RUN;
来源:https://stackoverflow.com/questions/22861944/cannot-import-text-delimited-file-with-unusual-characters-in-sas