BookmarkSubscribeRSS Feed
CarolynNorman
Calcite | Level 5

I am trying to locate a way to export my sas code into my results.   The purpose: create study notes in a SAS course I am taking, so that I can end up with the assigned task in the comments, the code I used, and the results. 

 

Example of what I need to do - I would like all of the below to appear in my results - the comment, the code, plus the results:

 

 

/**************************************************************************************************

Question 1: Figure out the mean and median weight from the data sashelp.bweight. 

**************************************************************************************************/

proc means data=sashelp.bweight Mean Median;

var weight;

run;

 

The SAS System

The MEANS Procedure

Analysis Variable : weight

Mean

Median

3370.76

3402.00

 

 

 

 

2 REPLIES 2
Ksharp
Super User

Assuming program.sas is the code you are running.

 

 

filename x '/folders/myfolders/program.sas';
data x;
infile x length=len;
input x $varying256. len;
run;
proc report data=x nowd noheader style={ rules=none frame=void asis=on};
run;
%include x / source2;

 

RW9
Diamond | Level 26 RW9
Diamond | Level 26

To me it sounds like your doing things the wrong way round.  First come the specifications, then the coding.  To put it another way, 90% of programming activites is documentation - specifcations, testing logs, help documentations etc.  The actual putting some code down is a very small part of it.  Your doing the reverse, your trying to create documentation from what you have coded.  This will not work on at least two fronts.  First you can't test the code, as you only know what it does, not what it should do.  Secondly change management, changes will never be captured as the documentation always shows what has run, no comparisons.

To be honest, if your metadata (specifcations) is robust enough, you don't even need to program, just generate the code directly.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1034 views
  • 2 likes
  • 3 in conversation