I used the following code and when I submitted, my raw data file is not in the proper order as I expected. I even used the word wrap but no use. What can be the solution?
Please post your code as text...I don't want to type it out to replicate your issue.
I'm fairly certain the export is fine, your text editor is muddling it up for some reason.
Try NotePad ++ instead perhaps.
This should show you exactly what is in the raw file.
0D0A is end of record windows CR/LF
0A is Unix end of record
It makes a difference it you ar erunning on Unix or Windows
HAVE A RAW FILE WITH BAD HEX CODES ( 0A and 0D for instance)
file c:/txt/badhex.txt
The records look fine in the log window
AAAAAAAAAAA
BBBBBB
AAAAAAAAAAA
BBBBBB
AAAAAAAAAAA
BBBBBB
WANT ( A lising like this to see the bad characters like 0A and 0D in the data
RULE: ----+----1----+----2----+----3----+-
1 CHAR AAAAAAAAAAA.BBBBBB..
ZONE 44444444444044444400
NUMR 11111111111A222222DA
2 CHAR AAAAAAAAAAA.BBBBBB..
ZONE 44444444444044444400
NUMR 11111111111A222222DA
3 CHAR AAAAAAAAAAA.BBBBBB..
ZONE 44444444444044444400
NUMR 11111111111A222222DA
SOLUTION
* create a bad file;
data _null_;
file "c:/txt/badhex.txt" lrecl=20 recfm=f;
do i=1 to 3;
txt=cats(repeat('A',10),'0A'X,repeat('B',5),'0D0A'X);
put txt;
putlog txt;
end;
run;quit;
* just pick and lrecl and recfm that is close to what your record length is and
use the code below. Then look for bad chars;
data _null_;
infile "c:/txt/badhex.txt" recfm=f lrecl=20;
input r20 $char20.;
list;
run;quit;
NOTE: The infile "c:/txt/badhex.txt" is:
Filename=c:\txt\badhex.txt,
RECFM=F,LRECL=20,File Size (bytes)=60,
Last Modified=22Aug2016:13:31:11,
Create Time=22Aug2016:13:24:00
RULE: ----+----1----+----2----+----3----+-
1 CHAR AAAAAAAAAAA.BBBBBB..
ZONE 44444444444044444400
NUMR 11111111111A222222DA
2 CHAR AAAAAAAAAAA.BBBBBB..
ZONE 44444444444044444400
NUMR 11111111111A222222DA
3 CHAR AAAAAAAAAAA.BBBBBB..
ZONE 44444444444044444400
NUMR 11111111111A222222DA
A better way is to use the old text editor and 'proc fslist'.
However this does not work well or at all in
(EE,EG,UE,SAS Studio)
filename fsl "c:\txt\badhex.txt' lrecl=20 recfm=f;
proc fslist file=fsl;
run;quit;
When the full screen editor comes up, you will need
a nice command line. This is where all the other editors fail.
On the command line type nums on;hex on;
You can use quite a few of the old text editor scripting commands
like find '0A'X;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.