PROC DTREE, PROC TREE, PROC SPLIT in SAS - sas

Is it possible to generate a simple tree with values at each node in SAS? I'm looking to create something simple like this:

I was interested in doing something similar a while back - printing a folder tree to the output area. I wasn't able to find a dedicated SAS proc that would work this way. The only method I know of that would allow you to create something like this (with quite a lot of effort) would be to write a macro to generate all the lines and captions in an annotation dataset, and then generate an image from it using proc ganno or proc gslide. See here for further details on using annotation datasets.

Related

SAS : ODS and code highlighting

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

Replace missing data in SAS with prediction: Regression Imputation

I have a SAS data set with missing data in multiple columns. I would like replace the missing data with a prediction based on the other data in the data set. Here a link that describes the method but doesn't show me how to do it. How do I replace the missing values with a prediction?
EDIT:
The method I had in mind was just using Proc Reg then apply the coefficents to the missing data to generate the estimate. Does this answer your question?
PROC STDIZE, PROC EXPAND, and PROC MI are all capable of performing different kinds of imputations on your data depending on exactly how you want do determine the 'prediction'.
For simple things like replacing with the mean, PROC STDIZE is the way to go. PROC MI is the most advanced - it performs multiple imputation. PROC EXPAND is appropriate if you have time-series data, as it will try to work out what the correct value is for that point in the time series.
If you have missing data in multiple columns you'll require multiple regressions. This probably isn't a good way to do this, but to answer the question - what you're requesting is called scoring a dataset and you can use PROC SCORE.
An alternative method is in your regression procedure request an OUTPUT data set that contains the predicted values for that regression.
output out=predicted1 p=pred_var_missing;
As a matter of methodology, I recommend #Joe's method instead.
Adding to #Joe 's answer, if you tell us why you want to do this imputation, we can provide better advice. I wrote a blog post called How to Ask a Statistics Question that may help.
However, often, single imputation is a bad method. More particularly, if you are going to do further analysis on this data (with the imputed values) then single imputation will underestimate the variability of the data and give wrong results.
PROC MI is usually a better approach.

How do I output a SAS data set looking exactly like my result in PROC TABULATE?

So I am a complete beginner in SAS and it seems that I am missing something that is very obvious since I cannot figure this out. Hopefully someone could help me on this.
I have disorganized data in a .csv file with which I need to compute some stuff for, but the first step before any of that is to organize my data into a workable data set in SAS. So first, I run a DATA step to import my .csv file. Then, I run a PROC TABULATE to make it look exactly how I want it to so that I can compute additional variables as follows:
PROC TABULATE DATA = Work.Temp OUT = Work.Final;
However, the outputted data set Work.Final looks completely different from what I was able to create in PROC TABULATE. Basically, I was able to get the data into the form I want using PROC TABULATE, and I want my outputted SAS data set to look exactly in this form. Instead, the data set Work.Final is again a disorganized mess.
Any thoughts?
Try using ODS output to write a CSV file from your Proc tabulate.
ODS CSV FILE=”C:\Final.CSV”;
PROC Tabulate data=work.temp;
class bla bla bla;
table etc etc;
RUN;
ODS CSV CLOSE;

Using PROC GENMOD in SAS how can I create a variable of just the model deviance?

In R I could just write something like model$deviance and model$df.residual, but I can't seem to find any way of doing this in SAS.
Whereas R functions produce an object that has sub-objects that you can extract into a variable, SAS procedures create tables. If you see a statistic in some table that you want to use in another part of your program, you can use the Output Delivery System (ODS) to write that table to a data set, as follows:
1) Use the ODS TRACE ON statement to discover the name of the table (or look it up in the documentation)
2) Use the ODS OUTPUT statement to write the table to a data set.
For example, if you are interested in the many goodness-of-fit diagnostic statistics (including the statistics for deviance and chi-square residuals), you can discover that the "Criteria for Assessing Goodness of Fit" table has the name ModelFit. Therefore, putting
ODS OUTPUT ModelFit=FitStatistics;
inside your PROC GENMOD call will create a data set called "FitStatistics" that contains the statistics you want.

SAS- PROC UNIVARIATE > histogram > x axis values

I have a single continuous variable with highly skewed distribution. I have log transformed it for normalization. while creating a histogram of the variable with PROC UNIVARIATE (SAS 9.3), is there a way by which I can plot the transformed variable, but keep the values of original variable on x axis ?
if this topic has been already discussed then, I would really appreciate if someone can provide a link. Thank You.
You could use the SAS Graph Template Language (GTL) to do this. The documentation contains plenty of examples that you should be able to change and modify to your needs. The output from PROC UNIVARIATE is produced by the GTL so you should be able to generate something similar.
Take the output dataset from proc univariate and base the plot off that. You will need to reverse the transformations first.
Documentation for the GTL:
http://support.sas.com/documentation/cdl/en/grstatgraph/65377/HTML/default/viewer.htm#p1sxw5gidyzrygn1ibkzfmc5c93m.htm