Building output dataset

Accepted Solution Solved
Reply
Contributor
Posts: 20
Accepted Solution

Building output dataset

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


Accepted Solutions
Solution
‎08-24-2016 10:48 AM
Super User
Super User
Posts: 7,970

Re: Building output dataset

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


All Replies
Solution
‎08-24-2016 10:48 AM
Super User
Super User
Posts: 7,970

Re: Building output dataset

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.

Contributor
Posts: 20

Re: Building output dataset

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.
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 214 views
  • 0 likes
  • 2 in conversation