BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mauri0623
Quartz | Level 8

******************************* NOTIF01 *******************************
rc = 0 after rm of enrollfee_notif0102.sas7bdat
rc = 0 after rm of mailing_notif0102.sas7bdat
rc = 0 after rm of pnt_notif0102.sas7bdat
Successful run of TMARPT_NOTIF01.sas at Mon Mar 4 02:10:02 EST 2019 RC=1
      ******************************* NOTIF02 *******************************
rc = 0 after rm of notif02_file
rc = 0 after rm of enrollfee_notif0102.sas7bdat
rc = 0 after rm of mailing_notif0102.sas7bdat
rc = 0 after rm of pnt_notif0102.sas7bdat
Successful run of TMARPT_NOTIF02.sas at Mon Mar 4 02:15:03 EST 2019 RC=1
       ******************************* NOTIF05 ********************************

 

How to align the titles?

I used left trim and it didn't work.

tit1 = left(trim("**************** NOTIF01 *****************************")); This is how the title is created.
Successful run of TMARPT_NOTIF05.sas at Mon Mar 4 02:40:01 EST 2019 RC=0
chmod: cannot access ‘/saswork/output/tma/report_output/NOTIF05-????-20190303.PIP’: No such file or directory
NOTIF05 Report Terminated at Mon Mar 4 02:40:01 EST 2019
Trying to chmod 775 /saswork/output/tma/report_output/NOTIF05-????-20190303.PIP
Return Code: 1
          ******************************* NOTIF06 *******************************
Successful run of TMARPT_NOTIF06.sas at Mon Mar 4 02:45:02 EST 2019 RC=1
switching directory to /saswork/output/tma/pnt/archive
making directory p20190303
chmod 755 p20190303
@

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Collapse the multiple variables into one variable before the PUT statement.

Either change each step to use the SAME variable name.

Or in the final step collapse them.

data _null_;
  set all;
  length line $200;
  line=catx(' ', of tit1-tit4 var1);
  file "/$ROOTDIR/qa_reports/NOTIF_SMRY_&todays_date..txt";
  put line ;
  file print;
  put line ;
run;

View solution in original post

11 REPLIES 11
RW9
Diamond | Level 26 RW9
Diamond | Level 26

And what software are you using?  This is a general programming board, and I have never seen titles created like that.  Do you use DI or something?  In terms of SAS code:

tit1=strip("**************** NOTIF01 *****************************");

However, its likely spaces are coming in from somewhere else.  So maybe put a newline in.

mauri0623
Quartz | Level 8

I am going to post some of the code hoping that it shed more lights.

 

filename in1
('/$ROOTDIR/output/tma/report_output/logs/STMA001_NOTIF01_run.log'
);
data log_anal1;
length fname filename $200;
infile IN1 truncover filename=fname;
input var : $ 3000.;
filename=fname;
var1 = _infile_;
run;

data tst1;
tit1 = left(trim("******************************* NOTIF01 *******************************"));
run;

data log_an1;
set tst1 log_anal1;
run;

NOTIF2, NOTIF5, and NOTIF6 are created in similar manners but they don't line up.

 

Kurt_Bremser
Super User

@mauri0623 wrote:

 

NOTIF2, NOTIF5, and NOTIF6 are created in similar manners but they don't line up.

 


If they were, they WOULD line up.

 

How do you create the output in your initial post?

mauri0623
Quartz | Level 8

Here is the entire code. The .txt file when is created the titles are not aligned.

 

filename in1
('/$ROOTDIR/output/tma/report_output/logs/STMA001_NOTIF01_run.log'
);
data log_anal1;
length fname filename $200;
infile IN1 truncover filename=fname;
input var : $ 3000.;
filename=fname;
var1 = _infile_;
run;

data tst1;
tit1 = left(trim("******************************* NOTIF01 *******************************"));
run;

data log_an1;
set tst1 log_anal1;
run;

filename in2
('/$ROOTDIR/output/tma/report_output/logs/STMA001_NOTIF02_run.log'
);
data log_anal2;
length fname filename $200;
infile IN2 truncover filename=fname;
input var : $ 3000.;
filename=fname;
var1 = _infile_;
run;

data tst2;
tit2 = left(trim("******************************* NOTIF02 *******************************"));
run;

data log_an2;
set tst2 log_anal2;
run;

filename in3
('/$ROOTDIR/output/tma/report_output/logs/STMA001_NOTIF05.log'
);
data log_anal3;
length fname filename $200;
infile IN3 truncover filename=fname;
input var : $ 3000.;
filename=fname;
var1 = _infile_;
run;

data tst3;
tit3 = left(trim("******************************* NOTIF05 ********************************"));
run;

data log_an3;
set tst3 log_anal3;
run;

filename in4
('/$ROOTDIR/output/tma/report_output/logs/STMA001_NOTIF06.log'
);
data log_anal4;
length fname filename $200;
infile IN4 truncover filename=fname;
input var : $ 3000.;
filename=fname;
var1 = _infile_;
run;

data tst4;
tit4 = left(trim("******************************* NOTIF06 *******************************"));
run;

data log_an4;
set tst4 log_anal4;

data all;
set log_an1 log_an2 log_an3 log_an4;
run;

data _null_;
set all;
file "/$ROOTDIR/qa_reports/NOTIF_SMRY_&todays_date..txt";
put tit1 tit2 tit3 tit4 var1;
file print;
put tit1 tit2 tit3 tit4 var1;
run;

RW9
Diamond | Level 26 RW9
Diamond | Level 26

I am a biit confused about why you are doing it this way in the first place, its a pretty inneficient method.  Also, I would highly recommend a review of naming conventions!

Now onto the why.  If you look at the all dataset you will see that there are rows where tit1 is missing, tit2 is missing etc.  This is because each one is only defined in the datastep it appears in, so does not cross across all datasets.  When the put to file happens is prints the empty space because you have asked it to with:
put tit1 tit2 tit3 tit4 var1;

on the first data part of all tit1 gets printed, on the second, missing gets printed as tit1 is empty, then tit2 gets printed, on the third, tit1 and tit2 are both printed as space, then tit3 etc. 

Kurt_Bremser
Super User
data _null_;
set all;
file "/$ROOTDIR/qa_reports/NOTIF_SMRY_&todays_date..txt";
put tit1 tit2 tit3 tit4 var1;
file print;
put tit1 tit2 tit3 tit4 var1;
run;

You put tit4 to the right of tit3, which is to the right of tit2, which is to the right of tit1. SAS will put at least a single blank for every variable.

Since your titles take a separate observation anyway, use var1 for them, and avoid all the tit: variables.

mauri0623
Quartz | Level 8

I did what you said and it did not work. Eliminating ti1, tit2, tie3, and tie4 the title won't show.

Tom
Super User Tom
Super User

Collapse the multiple variables into one variable before the PUT statement.

Either change each step to use the SAME variable name.

Or in the final step collapse them.

data _null_;
  set all;
  length line $200;
  line=catx(' ', of tit1-tit4 var1);
  file "/$ROOTDIR/qa_reports/NOTIF_SMRY_&todays_date..txt";
  put line ;
  file print;
  put line ;
run;
mauri0623
Quartz | Level 8

Thank you. This worked just the way I wanted it.

 

 

ballardw
Super User

You want to be careful with using SAS keywords in a different manner. TITLE generally will refer to an actual TITLE statement, which you are not using.

 

So far as I can tell none of the code you have posted creates any output at all. I see three data steps that create character variables but nothing that shows how you may be attempting to display them anywhere.

 

If you at a latter point are using "put" statements to generate text then alignment issues often come from creating text in code with a fixed width font such as SASMONO or COURIER and displaying such text with a destination using a proportional font such a Times New Roman or Arial. Spaces are rendered at different widths in proportional fonts and getting such to align from text manipulation is a tedious and often never-quite-correct result.

 

Show how you are generating your actual output using those values and we may have more ideas.

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
  • 11 replies
  • 1017 views
  • 0 likes
  • 5 in conversation