SAS and D3.js (1): a macro to draw scatter plot HTML is the default output format for SAS since 9.3. Implementing the popular JavaScipt frameworks such as jQuery and D3.js will allow some dynamic effects to the final HTML results. In those cases the HTML file is static, and thus no HTTP server is needed.At the beginning, I come up with a simple SAS macro to realize the scatter plot which is a SVG format picture on the canvas of a HTML page. 1. Transform SAS dataset to JSON JSON is the dominant data format for web. Actually I found that SAS’s dataset can be easily transformed to JSON . Here the SASHELP.CLASS ...
Use D3.js to draw pie chart instead of PROC GCHART Is the pie really round?Commonly the PIE statement in the PROC GCHART produces the pie charts. Given the shortcoming of the pixel based Gxxxxxx procedures, the boundary of the pie is not very clear. I always feel that the resulting pie is not 100% round. Let's see one example with a dataset from SAS's online document./* Set the graphics environment */goptions reset=all; /* Create the input data set SALES */data sales; input site $ 1-8 count; datalines;Atlanta 103Chicago 486Dallas 195Denver 400New York 307Seattle 577;run;/* Produce the chart */proc gchart data=sales; pie site / sumvar=count slice = inside value = none noheading; run;My ...
SAS and VBA (8): What VBA can do for SAS? The eventual answer is user interface (I really don't mean SAS/AF) with or without Excel.In the Windows environment, SAS provides data access layer by ADO and ADO.NET. We can build the applications using SAS at the backend through ADO.NET. Since Visual Basic.NET has the similar syntax to VBA, if somebody is comfortable to code in Microsoft's Visual Studio, then developing a desktop app is always feasible although it requires quite a few efforts.For example, let's run a simple linear regression using the variable of WEIGHT to predict HEIGHT based on the SASHELP.CLASS data set. We can use Excel's macro to fetch the output by SAS ...
SAS and VBA (6) : delete empty rows One tricky question of the data work is to delete empty rows/observations in a raw file. A code snippet is particular useful to handle such cases. At the mean time, we need to know how many rows are actually removed as the execution result. The good news is that as programmable softwares, Excel/VBA and SAS are both good at dealing this job. In a simple demo text file below, there are actually two empty lines that have to be removed. ptno visit weight1 1 122 1 2 1 3 1 4 123 2 1 156 2 3 3 1 112 3 2 ...
SAS and VBA (7): calculate running total This is a simple routine for a lot of reporting work. Many people tend to do it in Excel by dragging the range after entering the formula in the 1st cell. However, coding in VBA and SAS will usually do it in more prompt and safe way.VBA VBA’s unique R1C1 formula is pretty handy once we get to know the rule. The 1st cell at the F column has different R1C1 formula than the cells below.Sub Rt()' Find the last row FinalRow = Cells(Rows.Count, 2).End(xlUp).Row Range("F1").Value = "Running total of Weight" Range("F2").FormulaR1C1 = "=RC[-1]" Range("F3:F" & FinalRow).FormulaR1C1 = "=RC[-1] + ...