BookmarkSubscribeRSS Feed
nr1
Calcite | Level 5 nr1
Calcite | Level 5

Hi All,

 

 

I Need to add a  some text ( 'Note statements') at the end of my text file.

eg :

 

MBCE|WBSRV||||1305|19-07-2017|C|C|By /5346/JEESHMA B R|0||0|6250||6250|0|0|0|6250|190717FB139051
MBCE|WBSRV||||1305|19-07-2017|C|C|By /5013/AJAY VINOD|0||0|81250||81250|0|0|0|81250|190717FB141101

 

Note:'ALL DATA NOT REFLECTED IN REPORT'.

 

How to add this note statement.

7 REPLIES 7
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Why, this is not inline with delimited text files?  First row contains headers (can be omitted), each following row is a row of data delimited by a given character - this breaks that and adds additional problems for the importer.  If you need to confirm something then this should be included in the manifest/import agreement/validation summary etc. not as part of the datafile.  This file would not pass my acceptance testing.

 

That being said, you will ignore all that and carry on anyway, so in your datastep which you write the data out (you do use datastep yes?) put:

data _null_;
  set have end=last;
  file "xyz.txt" dlm="|";
  ...
  if last then put "....";
run;

Again though, I would fail it as the datatype is not valid in any sense.

nr1
Calcite | Level 5 nr1
Calcite | Level 5

Hi Sir,

 

Thanks for your response.

 

Yes i do have a data set which contains all the values.

 

data _null_;
  set have end=last;
  file "xyz.txt" dlm="|";
  ...
  if last then put "....";
run;
Now i have executed this code by giving my datset and in put statement the required lines.But only the last

line got excuted.data went missing and only the last line (in put statement)got printed.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

This is just a shell code for example, you need to populate it with the data you have:

data _null_;
  set have end=last;
  file "xyz.txt" dlm="|";
  put var1 var2...;
  if last then put "....";
run;

 

ballardw
Super User

@nr1 wrote:

Hi All,

 

 

I Need to add a  some text ( 'Note statements') at the end of my text file.

eg :

 

MBCE|WBSRV||||1305|19-07-2017|C|C|By /5346/JEESHMA B R|0||0|6250||6250|0|0|0|6250|190717FB139051
MBCE|WBSRV||||1305|19-07-2017|C|C|By /5013/AJAY VINOD|0||0|81250||81250|0|0|0|81250|190717FB141101

 

Note:'ALL DATA NOT REFLECTED IN REPORT'.

 

How to add this note statement.


A question: Is this text file to be read by another computer program as input data? If so does that program know how to read a blank line followed by your note and NOT treat it as data?

 

 

Tom
Super User Tom
Super User

Sounds like really dumb idea.

But if you really want to do it then just add it when you create the file.

Or you can just add it later in a sperate step. Let's assume your file is named 'myfile.txt'.

data _null_;
  file 'myfile.txt' mod ;
  put / "Note:'ALL DATA NOT REFLECTED IN REPORT'" ;
run;
nr1
Calcite | Level 5 nr1
Calcite | Level 5

Thank You,

 

 

i am using proc export statement 

eg:PROC EXPORT DATA=a;

  OUTFILE= "location.txt"
DBMS=TAB replace;
putnames=no;
DELIMITER='|' ;
RUN;

 

this will give the data in txt format but need to add a footnote to this text file.any options for this

RW9
Diamond | Level 26 RW9
Diamond | Level 26

No.  Proc export will only create a valid delimited file, your not creating a valida delimited file so you need to do it yourself.  Also, you might want to clarify what you want out:

DBMS=TAB - this indicates a tab delimited text file however

DELIMTER='|' - this indicates a pipe delimited text file.

Also avoid coding in mixed case, it makes code hard to read and use code blocks - its the {i} above the post to avoid formatting issues.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 7 replies
  • 1202 views
  • 0 likes
  • 4 in conversation