/*This program calculates binomial percentages and confidence limits.
Howver, this has no correction methodology so the lower bound can go below 0.
In this case a different method is needed*/
*set table name to summarize;
%let dsin=sashelp.class;
*set variable name to get percentages;
%let var = sex;
*set name of output data set;
/*this creates a list of combinations, designed for numeric variables*/
%let n=5; /* total number of items */
%let k=2; /* number of items per row */
/* generate combinations of n items taken k at a time */
data Comb(keep=c1-c&k);
array c[&k] (&k.*0); /* initialize array to 0 */
array list[&n] _temporary_ (1, 2, 3, 4, 5);
ncomb = comb(&n, &k); /* number of combinations */
do j = 1 to ncomb;
/*This program checks if two variables exist in a data step and then does conditional logic
if the variables are present
This is also an example of CALL VNEXT()*/
/*Generate sample data*/
*both variables exist;
data class1;
View sas_mlf_format
/*This program shows how an multilabel format works and that the summary statistics can be done at a unique level but also aggregated at a higher level included in the data.*/
/*sample data*/
data have;
input Year Area $ Profit;
2001 A 1
2002 A 2
2001 B 1
2001 C 3
/*This is an example of how to create multiple macro variables in
one SQL step.*/
*note that you do not need to specify the number of items;
*SAS will do that portion for you;
proc sql noprint;
select name into :name1- from sashelp.class;
%put &name1;
/*This is an example of doing calculations with a macro variable.
In this case, all integers allow us to use %EVAL(). Otherwise you
would need to use %SYSEVALF()*/
%let HYR = 2018;
%Let Yr2 = %eval(&HYr. - 1);
%Let Yr5 = %eval(&HYr. - 4);
%put HYR: &hyr;
%put YR2: &yr2.;
/*This program is based on the question here:
The purpose is to create a correlation heatmap from a correlation matrix.
Author: F. Khurshed
Date: 2018-04-20
ods output PearsonCorr=Corr_P;
/*This program will take a folder path (default) and look for files
that are specifically with the specified extension (ext) and convert
the files to CSV. It uses XCMD so you need to have that option enabled.
The original script is from here:
Modified to convert XLSX to CSV.
Author:F. Khurshed
Date: 2018-03-23
View SAS_demo_format
/*This program demonstrates how a built in SAS format works.
It uses the WORDS format to display the age as thirteen rather than 13.
It also creates two additional variables, one is numeric and formatted,
the second is a character variable with the same value
Author: F.Khurshed
Date: 2018-03-23
*Create a sample data set;
/*This program is used when you want multiple m*n tables and you want it summarized. In this case the one variable, SEX is in the
KEEP statement, this will change depending on the variables in the code*/
ods output crosstabfreqs=summary;
proc freq data=sashelp.class;
table sex*(_all_);