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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 803 views
  • 2 likes
  • 3 in conversation