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

I'm having some difficulty trying to create an output dataset in the format I want. Essentially I'm reading in a dataset, If that dataset is not empty than I would like to add some static commentary to my output, then write each record out. All I can get is the static output to repeat for each record, which I don't want.  

 

DATA _NULL_;                                               
   set three;                                              
   file msg02;                                             
    put  '**********************************************' ;
    put  '*** blah 1                                       ***' ;
    put  '*** blah 2                                       ***' ;
    put  '*** blah 3                                        ***' ;
    put  '**********************************************' ;
   put @02 name @15 num @25 message;                 

 

 

I hoping to see output like this –

 

 Static Blah 1

 Static Blah 2

 Static Blah 3

 

 Record 1

 Record 2

 Record 3

 

I removed the check for an empty file as I wasn't sure that wasn't causing me issues, so am just trying to get this to work for now.

 

PROC Print of the dataset using the title option gives me what I want, and I can redirect the SASLIST to a dataset, however I also still need it within my log output. If there is an option to have the SASLIST both redirected to a dataset and kept in the log that should also work for me, though I assume building it as above is probably the route to go.

 

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Sorry, thats not making sense to me.  You talk about building a dataset, but provide code which would create an output text file.

If you want to print that header info only once, thenput an if around it:

data _null_;                                               
   set three;                                              
   file msg02;
   if _n_=1 then do;                                             
    put  '**********************************************' ;
    put  '*** blah 1                                       ***' ;
    put  '*** blah 2                                       ***' ;
    put  '*** blah 3                                        ***' ;
    put  '**********************************************' ;
   end;
   put @02 name @15 num @25 message;      
run;

However a quesiton arises why you want that kind of output, its not easy to process.  Lokos like its some sort of program header template?  The whole re-directing to dataset doesn't make sense.

View solution in original post

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Sorry, thats not making sense to me.  You talk about building a dataset, but provide code which would create an output text file.

If you want to print that header info only once, thenput an if around it:

data _null_;                                               
   set three;                                              
   file msg02;
   if _n_=1 then do;                                             
    put  '**********************************************' ;
    put  '*** blah 1                                       ***' ;
    put  '*** blah 2                                       ***' ;
    put  '*** blah 3                                        ***' ;
    put  '**********************************************' ;
   end;
   put @02 name @15 num @25 message;      
run;

However a quesiton arises why you want that kind of output, its not easy to process.  Lokos like its some sort of program header template?  The whole re-directing to dataset doesn't make sense.

serge68
Calcite | Level 5
Sorry, by dataset I was referring to a ZOS/mainframe dataset(an output file) not a SAS dataset.

What you gave me is exactly what I need.

Appreciate it.

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
  • 2 replies
  • 570 views
  • 0 likes
  • 2 in conversation