When using R markdown for making statistical reports, I have the ability to echo the R code in my output document. I'm learning SAS and I was wondering if it was possible to highlight or echo the SAS code in my final ODS report ? I'm using a dirty hack right know to display the code in my document, which is using "ods text = ", but it seems quite redundant. Plus it doesn't add syntax highlighting.
That feature does not exist in the SAS language right now, but it has been mentioned in several talks by Amy Peters, principal product manager of the SAS programing environments, as a planned feature for a near-future SAS release (with no specific date yet, but hopefully in the next 2 years). It would likely be implemented in a similar fashion to Jupyter Notebooks, in that you write your code and get your output inline.
That said, SAS does support Jupyter Notebooks, which is the best current (third party) solution. Contact your SAS administrator for more information.
I have an idea here, I'm the type of guy who dosent take no for answer and find a way to fiddle and get it done... but i think this is abit far fetch... you can try still I think it will work with mostly evrything but may have a hard time to play with quotes when you have multiple semi colomns....
Check:
I started by creating a dumbass dataset :
data tata;
x=1;
run;
then we do the following:
%let code= select * from tata;
proc sql;
create table report as
&code.;
quit;
proc print data=report;
footnote "&code.";
run;
The rationale:
I think it you put your code in macrovariables and then execute those macro variables you would be able to print show the code after by printing the macrovariable following your text...
See the sample
Related
What can we do with proc report that we cannot do with proc print?
They seem very similar in usage. It seems that they are both used to create a list style report
PROC Report is a more advanced feature as compared to PROC PRINT , which gives a listing kind of report. I don't say that print procedure is bad, as we used to use it before in a different fashion. The additional features of PROC REPORT stand out against PRINT procedure,
Ability to compute a variable and display it in the final report on the fly - using COMPUTE block
No pre-sorting required, you can do that using define <> /
Ability to add free style text and proper breaks for TOTALS - you can control this properly in report where as you have less control in PROC PRINT.
There are many others, but the above few I found a lot useful and differentiating as per me, others can add more though.
I'm having a wee bit of a problem and I was hoping someone out there has a magic solution.
At present we run a bit of code on SAS 9.3 that uses DDE to populate an excel template - populating text from cells B2:M24 - these are character or text fields with no formulae. This does work, but we're moving to Enterprise Guide 5.1 and I need something that will work on there.
I'm pretty new to Enterprise Guide and I've googled this until my head is about to explode and so far, nothing has worked. We can't just do a manual export as this will be a scheduled job.
Presumably there is a way to do this that I'm missing. Can anyone point me in the right direction please?
Managed to get it done through PC Files server using named range in Excel.
libname xls PCFILES path="C:\Template.xls" server=<Server> port=<port>
user= pass= ;
proc datasets lib=xls nolist;
delete <named range>;
quit;
data xls.<named range>;
set <named range>;
run;
libname xls clear;
Probably not the most elegant way but it got the job done.
Thanks anyway.
I have a sas output, and for each person have some information. But each person is supposed to be on a separate page when printed out, in other words that PDF should be one page for each person. I didn't use macro in my code. Also I don't know how to make macro. So is there any way that I can separate pages without using macro?
Code:
data _null_;
set maingroup;
call execute('%bygroup(' || trim(maingroup) || ')');
run;
This code separate the people for each page. But I don't have macro, I changed the code little bit. Check the report as below.:
Ayda Ceyhan: 325
1258 458
Grade:3.0
Issues: Test
-------
Justin Costay: 526
1568 132
Grade:3.5
Issues: NA
This is the output, there are two people in here. I need them to separate for each page when print out.
This depends largely on your actual report; but in general, you should be able to use by groups rather than using macros.
A simple example:
ods pdf file="c:\temp\test.pdf" startpage=bygroup;
proc report data=sashelp.class nowd;
by name;
columns age sex height weight;
run;
ods pdf close;
The startpage=bygroup tells the PDF engine to print out a new page for each by group. You might need to use notsorted if your by variable cannot be sorted on. This may or may not exactly do what you want, depending on how you're producing the report.
If you're doing this with data step programming, you may have a harder time without having access to the macro that's doing it. I honestly wouldn't use data step programming; nowadays, proc report/tabulate/etc. are very good at producing reports in whatever format you want, and they're much more powerful than data step programming.
In your specific simple example, you may be able to issue ods pdf startpage=now; commands via call execute (and then use startpage=never on the original ods pdf statement).
Hopefully someone out there will have run into this before. I'm trying to use the street level geocoding capability of SAS' PROC GEOCODE, but I keep getting a cryptic error. I couldn't find anything on the net about it (although to be fair I only spent a half hour looking).
First, I'm using SAS Enterprise Guide (I've tried on both v4.2 and v4.3), although I still prefer to program as I find the point and click interface quite limiting. Maybe this right here is my problem?
Anyway I first get the lookup data sets from http://support.sas.com/rnd/datavisualization/mapsonline/html/geocode.html and follow the instructions in the readme. I also use the pre-written SAS program to import the CSV files. My input dataset contains just 4 variables: street address, city, state, and zip. I then run the following code:
libname josh 'C:\Users\Josh\Desktop\Geocode\SAS files';
proc geocode
method=street
data=SASUSER.Home_Policy_Address_Detail
lookupstreet=josh.USM
out=test;
run;
However I get this error:
ERROR: Variable NAMENC not found in JOSH.USM data set.
Nowhere in the readme or the import program is a variable named "NAMENC" ever mentioned. This is what has me stumped. Is it something wrong with the simple PROC GEOCODE program I wrote? Is it due to me using SAS EG (although I've yet to run into a base SAS procedure that hasn't worked on EG)? Or something else?
Any help/guidance would be much appreciated. Thanks in advance!
Check your SAS version. You can use the 'Help' menu in DMS mode or submit this statement:
%put &sysvlong;
It looks like you are using SAS 9.3 but your lookup data JOSH.USM is the lookup data formatted for SAS 9.4.
PROC GEOCODE street lookup data comes in two slightly different formats, one for SAS 9.3 and another for 9.4. When you download the nationwide lookup data from the SAS MapsOnline geocoding page, make sure to download the version appropriate for your SAS release.
I have a large SAS dataset and I would like to make a series of tables and charts using by value processing. I am outputing these to a PDF.
Is there any way to get SAS to alternate between the table and the chart as it goes through the data? Right now, I have to print all of the tables first and then print the charts. If it were just 4 tables/charts, then I would be ok writing
Here is a simple example:
data sample;
input byval $ item $ amount;
datalines;
A X 15
A Y 16
A Z 12
B X 25
B Y 10
B Z 18
;
run;
symbol1 i=j;
proc print data=sample;
by byval;
var item amount;
run;
proc gplot uniform data=sample;
by byval;
plot amount*item;
run;
This prints 2 tables, followed by 2 charts.
I would like the Chart for "A" to come after the table for "A" so that the reader can flip through the pdf and always see the associated charts and tables together.
I could write separate procs for each one, but then the gplot won't have a uniform axis (and it gets messy if I have 100 different groups instead of 2).
I thought about pumping them into greplay but then you can't use titles with "#BYVAL1".
Is there any easy way to do this?
I've never used it, but it may be worth checking out ODS DOCUMENT. This allows you to store the output of all your procedures and then reference specific items from them using PROC DOCUMENT.
Below is a link to the SAS website with useful information about this, in particular the paper by Cynthia Zender for the SAS Global Forum 2009.
http://support.sas.com/rnd/base/ods/odsdocument/index.html
Cynthia also regularly contributes to the SAS Support Communities website (https://communities.sas.com/community/support-communities), so it may be worth asking on there if you are still stuck.
Good luck
I don't know of any way to do what you ask directly. GREPLAY is probably the closest you'll come; the primary problem is that SAS processes the PROCs linearly, first processing the entire PROC PRINT, then the entire PROC GPLOT. GREPLAY would allow you to redisplay the output, but if that doesn't work for your needs due to the #BYVAL issue, I'm not sure there's a better solution. Perhaps you can modify the title afterwards (not sure if GREPLAY allows this)?
You could try using ODS LAYOUT, but I don't think that would be any better. The one way it could be better is if you can work out having two columns on a 'page', one column being the PROC PRINT outputs, one the PROC GPLOT, and then print the columns one page than the other. I don't think this is possible, but it might be worth exploring.
You might also try setting up a macro to do each BYVAL separately, defining the axis in a uniform manner manually (ie, defining it based on your own calculation of the correct axis parameters, as an argument to the macro). That is probably the easiest solution that might still allow #BYVAL to work properly.
You might also try browsing about Richard DeVenezia's site (http://www.devenezia.com/downloads/sas/samples/ ) which has a lot of examples of SAS/GRAPH solutions. He also posts on SAS-L (sasl#listserv.uga.edu) sometimes, not sure if I've seen him on StackOverflow. He's probably the person most likely to be able to answer the question that I know of.