BookmarkSubscribeRSS Feed
Kelkro
Fluorite | Level 6

Hi all, 

I have never posted in this community before but I feel like I have tried everything. 

I have been working on a request to get an export from SAS dataset to a .DAT file but it must be 1 line for the automation job to pick it up. 

When I export it seems like the line in the .DAT file (opens in NOTEPAD) will break to a new line at the 1025 column size. 

Does anyone have any ideas on how to expand this column size?? 

 

This is my current code: 

 

data _null_;
file "test.dat" recfm=N dsd dlm='Ñ' lrecl=500000;
set have end=eof;
put (_all_)(:) +(-1) @;
run;

 

This is what i see in the .DAT file export- It will break at the 1025 column .. no spaces there or anything to throw it off as that number continues onto the second line...

Kelkro_1-1668096546710.png

Kelkro_2-1668096563520.png

 

 

5 REPLIES 5
Reeza
Super User
Notepad has a 1024 line limit.
View the file with a different editor (Notepad++), check it by reading it back in via SAS or looking for an EOL character.

https://superuser.com/questions/431352/how-to-view-text-files-with-line-length-more-than-1024
Kelkro
Fluorite | Level 6

Thanks! I did check with notepad++ and it does seem to be one one line. Hoping the job can pick it up that way.

ErikLund_Jensen
Rhodochrosite | Level 12

Hi @Kelkro 

 

I have tried with the following code and it works perfectly well.

 

It shows one line with a length of 27.894 when the file is viewed in Notepad++, but my Notepad also breaks the file in lines, only  it breaks the file in 1139 bytes lines instead of 1025 bytes, but the problem is the certainly the editor, not your excellent code. 

 

data have;
  do i = 1 to 1000;
    Id = put(i,z8.);
    Name = 'VariableValue';
    Ltype = put(mod(i,3),2.);
    output;
  end;
run;

data _null_;
  file "c:\temp\test.dat" recfm=N dsd dlm='Ñ' lrecl=500000;
  set have end=eof;
  put (_all_)(:) +(-1) @;
run;
Kelkro
Fluorite | Level 6

Thank you for your help! I really appreciate it!

Tom
Super User Tom
Super User

You are just using the wrong tool to LOOK at the file.

 

Why not just look at it with SAS?

 

Example:

5    data _null_;
6      file 'c:\downloads\test.dat' recfm=n ;
7      put 200*'----+----0' ;
8    run;

NOTE: UNBUFFERED is the default with RECFM=N.
NOTE: The file 'c:\downloads\test.dat' is:
      Filename=c:\downloads\test.dat,
      RECFM=N,LRECL=256,File Size (bytes)=0,
      Last Modified=10Nov2022:12:54:42,
      Create Time=10Nov2022:12:53:14

NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


9
10   data _null_;
11     infile 'c:\downloads\test.dat';
12     input;
13     list;
14   run;

NOTE: The infile 'c:\downloads\test.dat' is:
      Filename=c:\downloads\test.dat,
      RECFM=V,LRECL=32767,File Size (bytes)=2000,
      Last Modified=10Nov2022:12:54:42,
      Create Time=10Nov2022:12:53:14

RULE:     ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
1         ----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0
     101  ----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0
     201  ----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0
     301  ----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0
     401  ----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0
     501  ----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0
     601  ----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0
     701  ----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0
     801  ----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0
     901  ----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0
    1001  ----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0
    1101  ----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0
    1201  ----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0
    1301  ----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0
    1401  ----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0
    1501  ----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0
    1601  ----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0
    1701  ----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0
    1801  ----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0
    1901  ----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0 2000
NOTE: 1 record was read from the infile 'c:\downloads\test.dat'.
      The minimum record length was 2000.
      The maximum record length was 2000.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


If you want to extra sure the file does not have any end of line characters in it then read it back as fixed length records instead.

50   data _null_;
51     infile 'c:\downloads\test.dat' recfm=f lrecl=100 ;
52     input;
53     list;
54   run;

NOTE: The infile 'c:\downloads\test.dat' is:
      Filename=c:\downloads\test.dat,
      RECFM=F,LRECL=100,File Size (bytes)=2000,
      Last Modified=10Nov2022:12:58:30,
      Create Time=10Nov2022:12:53:14

RULE:     ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
1         ----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0
2         ----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0
3         ----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0
4         ----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0
5         ----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0
6         ----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0
7         ----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0
8         ----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0
9         ----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0
10        ----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0
11        ----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0
12        ----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0
13        ----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0
14        ----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0
15        ----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0
16        ----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0
17        ----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0
18        ----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0
19        ----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0
20        ----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0
NOTE: 20 records were read from the infile 'c:\downloads\test.dat'.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 860 views
  • 4 likes
  • 4 in conversation