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
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;
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...
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;
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.