proc mean data =table A mean;
var interestRate;
run;
The variable interest rate is already in percentage format in table A. But the proc means doesn't return the results in percentage.
How to get the mean interst rate in percentage format when doing the proc means?
I don't believe there's any way to format the output directly. You can use a format statement to change how the data would be formatted in an output dataset, and then use PROC REPORT or similar to produce output similar to PROC MEANS output. You might also consider PROC TABULATE if it's a fairly simple table.
Related
The PROC Freq function generates a frequency table with the percentage, and the frequency of the variables. Is there a way to store the percentage of the variable for later use (like use this value to create dataset, create graphs)?
ODS OUTPUT is your friend any time you want to take the results of a PROC. Many procs, including PROC FREQ, also have output options built-in, but the generic one is ODS OUTPUT.
First, use ODS TRACE to identify the (internal to SAS) name of the table you need.
ods trace on;
proc freq data=sashelp.class;
tables age;
run;
ods trace off;
This generates:
Output Added:
-------------
Name: OneWayFreqs
Label: One-Way Frequencies
Template: Base.Freq.OneWayFreqs
Path: Freq.Table1.OneWayFreqs
-------------
Now you can use that with ods output:
ods output OneWayFreqs=myfreqdata;
proc freq data=sashelp.class;
tables age;
run;
ods output close; *this is technically not needed, but I like to have it for clarity;
It will make a table called myfreqdata (name that something useful please!). It isn't always "pretty"; sometimes you are better off using the built in output options in a proc, because they're more usefully formatted, but usually you can get somewhere from it.
Good afternoon,
It sounds like you want to output the results of the PROC FREQ to a SAS dataset. This will allow you to use them later, whether it is for further analysis or visualization. To do that, simply pass the a dataset name to the out= option after the table statement. You will notice below I also used the noprint option. This avoids needlessly printing the table.
For example,
proc freq data=work.dataset noprint;
table var1*var2 / out=work.output_data;
run;
I hope this helps!
I have a dataset with Yes / No values.
I've figured out that I can use Proc Freq to generate a table of "One-Way" results which displays the proportion per row i.e. 60% yes, 40% no. However, this is shown in a pop-up window by default.
I want to save these results to a dataset for potential manipulation but I can't figure it out. Searching online it says I need to enter additional commands in the table and output statement for this to work. This is my sample (incorrect) code:
proc freq data = results noprint;
tables check / pct_row;
output out = table1;
run;
Close, the OUT goes after the / on the TABLES statement.
proc freq data = results noprint;
tables check / out=table1 pct_row outpct;
run;
In the SAS proc logistic output, is there a way to rank-order by decreasing value of Wald's Chi square statistic?
Here's a link to an example of using ODS to write procedure output to a SAS dataset. The example uses proc genmod, but the concept applies to proc logistic as well. The documentation for proc logistic contains all of the ODS table names produced by the proc. Find the one you are interested in, write it out to a data set, and sort it however you desire.
I try to use the proc transreg procedure in SAS, to transform one of my variables in a dataset (var1). The var1 variable has values >=0.
My code is:
proc transreg data=data1 details;
model boxcox(var1/lambda=-1 to 1 by 0.125 convenient parameter=1)=identity(var2);
output out=BoxCox_Out;
run;
However I get the following error message:
"observation of nonblank TYPE not equal 'Score ' are excluded from the analysis and the output data set.
Could anyone help me?
_TYPE_ can be used for TRANSREG to allow you to take datasets with multiple kinds of rows and only use the SCORE rows (or whichever ones you choose), often outputs from earlier TRANSREG procedures.
However, _TYPE_ is also a common variable added by procedures like PROC MEANS to indicate which class combinations apply to the row. In this case, TRANSREG is getting confused and thinking you want something different.
Drop the _TYPE_ variable in the TRANSREG data source statement, and it should use all rows.
proc transreg data=data1(drop=_type_) details;
I'm running the following PROC MEANS command, but would like to suppress the value of SUM for the variable margin, as the sum of this percentage has no meaningful value.
proc means data=have N sum mean median maxdec=2 order=freq STACKODS;
var turnover margin;
run;
Is there any way to specify the statistics to be output according to each variable? I'm output much more than the sample code above and am creating Latex markup code automatically from the output, so it would be very helpful if the SUM for the variable margin was missing.
Thanks again for the help.
Do you need to use proc means?
I believe you can achieve your desired outcome using Proc Tabulate. Check out the attached:
http://www2.sas.com/proceedings/forum2008/264-2008.pdf