BookmarkSubscribeRSS Feed
SamuelRajKandru
Quartz | Level 8

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?


non fixed values.png
5 REPLIES 5
Reeza
Super User

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.

 

SamuelRajKandru
Quartz | Level 8
data _null_;
set sasuser.stress;
file '/folders/myshortcuts/Desktop/stress.txt';
put ID $ 1-4 Name $ 6-25 RestHR 27-29 MaxHR 31-33 RecHR 35-37
TimeMin 39-40 TimeSec 42-43 Tolerance $ 45;
run;
Cynthia_sas
SAS Super FREQ
Try opening your file with Word and see whether the Unix carriage return/line feeds are respected. That is one suggestion, there is another option that you specify that you use TERMSTR=CRLF on the FILE statement as an option to have a PC carriage return/linefeed written out for the end of record mark. Check the Unix documentation for value of TERMSTR=.

cynthia
rogerjdeangelis
Barite | Level 11
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;

sas-innovate-2024.png

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.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 2003 views
  • 2 likes
  • 4 in conversation