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

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.

 

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