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
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.
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.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.