BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
ajulio4
Obsidian | Level 7

i just realize that in my file, records end by "."

 

42  CHAR  TESSE;NOMBREDEKM;PRIXTTCDUVEHICULE;ETAPEDUPROJET.PFS;0015211;K;20200425;18:48:58;GMF-K0000015211;Roc
    ZONE  5455434444544444355455544554444544345454455544450545333333333433333333333333333334442433333333333566
    NUMR  45335BEFD22545BDB029844345658935C5B541054502FA54A063B0015211BBB20200425B18A48A58B7D6DB0000015211B2F3
43        ketLawyer;218ab553c7f34dd8;RocketLawyer-DocumentJuridique;;;;;;;;;;;;;;;;;Immobilier;;;;;;;;;;;;;;;;
44        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
45        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Particulier;;;;;;;NON_PJ;;;;;;;;;;;

46  CHAR  ;;;;;;;;;;;;;;;;;;;;;;;;;;;.PFS;0015211;K;20200425;18:56:00;GMF-K0000015211;RocketLawyer;19bb4713444
    ZONE  3333333333333333333333333330545333333333433333333333333333334442433333333333566667467767333663333333
    NUMR  BBBBBBBBBBBBBBBBBBBBBBBBBBBA063B0015211BBB20200425B18A56A00B7D6DB0000015211B2F3B54C17952B19224713444
47        9d21f;RocketLawyer-DocumentJuridique;;;;;;;;;;;;;;;;;Immobilier;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
48        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
49        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Particulier;;;;;;;NON_PJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

50  CHAR  ;;;;;;.PFS;0015211;K;20200


 every record of my file must begin with PFS

Tom
Super User Tom
Super User

So if the lines end with linefeed ('0A'x) and the embedded line breaks also use ('0A'x) then you cannot tell them apart.

But if you can check if the line starts with 'PFS;' then you can probably remove most of the extra line breaks by just checking for that.

data _null_;
  infile 'badfile' termstr=lf ;
  file 'goodfile' recfm=n ;
  input ;
  if _n_>1 then do;
    if substrn(_infile_,1,4)='PFS;' then put '0D0A'x;
    else put '0A'x;
  end;
  put _infile_;
run;

data want;
  infile 'goodfile' termstr=crlf dsd dlm=';' truncover;
  input (var1-var8) (:$30.);
run;

 

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
  • 16 replies
  • 1755 views
  • 2 likes
  • 4 in conversation