BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
DartRodrigo
Lapis Lazuli | Level 10

Hi,

Guys, i need to create a external txt file with finame and file statements as follows:

filename out "/home/mm14532/sasuser.v92/FRAUDEEM.txt";

data _null_; set ABECS_V4;
file out ;
put "/home" #2 @2 POS_MODE_OLA @3 DOM_INT @4 PAIS @54 OLA_MIS_MERCH_CAT @58 QUANTIDADE @70 VALOR @85 TIP_PESS @87 FORM_PAG @88 ANO @92 MES;

run;

This code is working well, but i need a way to put at the first line of this external file a string or a title.

I've tried using #2 to go to the second line but it didn't worked.

How can i do that ?

Thank you before anything

Rodrigo Elias

1 ACCEPTED SOLUTION

Accepted Solutions
Haikuo
Onyx | Level 15

Not tested, but can you just add a line:

filename out "/home/mm14532/sasuser.v92/FRAUDEEM.txt";

data _null_; set ABECS_V4;
file out ;

if _n_=1 then put "/home" ;

else put @2 POS_MODE_OLA @3 DOM_INT @4 PAIS @54 OLA_MIS_MERCH_CAT @58 QUANTIDADE @70 VALOR @85TIP_PESS @87 FORM_PAG @88 ANO @92 MES;

run;

View solution in original post

2 REPLIES 2
ballardw
Super User

filename out "/home/mm14532/sasuser.v92/FRAUDEEM.txt";

data _null_;

set ABECS_V4;
file out ;

if _n_ = then put "stuff here will be the first line in the output file";
put "/home" @2 POS_MODE_OLA @3 DOM_INT @4 PAIS @54 OLA_MIS_MERCH_CAT @58 QUANTIDADE @70 VALOR @85 TIP_PESS @87 FORM_PAG @88 ANO @92 MES;

run;

The automatic variable _n_ relates to the record currently being read from the dataset on the set statement.

You could use it for all kinds of conditional processing for old school output like this.

Examples:

if mod(_n_,80) = 0 then put "this is a multiple of 80 lines in the file";

or put the values of some specific variables, possibly you've been accumulating totals...

Haikuo
Onyx | Level 15

Not tested, but can you just add a line:

filename out "/home/mm14532/sasuser.v92/FRAUDEEM.txt";

data _null_; set ABECS_V4;
file out ;

if _n_=1 then put "/home" ;

else put @2 POS_MODE_OLA @3 DOM_INT @4 PAIS @54 OLA_MIS_MERCH_CAT @58 QUANTIDADE @70 VALOR @85TIP_PESS @87 FORM_PAG @88 ANO @92 MES;

run;

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!

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
  • 2 replies
  • 391 views
  • 3 likes
  • 3 in conversation