View SAS_combine_multiple_rows_into_one.sas
*create sample data for demonstration;
data have;
infile cards dlm='09'x;
input OrgID Product $ States $;
cards;
1 football DC
1 football VA
1 football MD
2 football CA
3 football NV
View SAS_Create_an_anonymized_key.sas
/*This program demonstrates how to create a basic anonymized
key for a unique identifier. Ensure you set the value in CALL
STREAMINIT()/RANDOM_SEED macro variable to ensure you can
replicate the keys if needed*/
%let random_seed = 30;
*list of unique values;
proc sql;
create table unique_list as
View sas_moving_averages_proc_means
proc sql noprint;
select min(period) into :min_period TRIMMED
from have;
select max(period) into :max_period TRIMMED
from have;
quit;
%put &min_period;
%put &max_period;
View sas_proc_sort_duplicate_keys
/*This example demonstrates how to get a list of duplicates based on the key variables.
KEY variables are placed in the BY statement.
Any 'duplicates' according to the KEY variables are kept in the OUT= dataset
*/
*Generate sample data with duplicate KEY;
data class;
set sashelp.class sashelp.class(obs=5);
run;
View sas_categorize_variable
data class;
set sashelp.class;
length category $20.;
bmi = 703*(weight/(height**2));
if bmi < 18 then
category='Under Weight';
else if 18 <= BMI < 25 then
category='Normal';
else if 25 <= BMI < 30 then
View sas_format_proc_means_summary
/*Note that if you apply formats to your date they get grouped according to the format, so having a SAS date is advantageous.
Here's a quick example that shows the calculating of yearly statistics from a data set.*/
proc means data=sashelp.stocks min max mean;
class date;
format date year4.;
var open high low;
run;
View sas_macro_variables_loop
/*Demo to show how to loop through a list of macro variables*/
proc sql noprint;
select name into :name1-
from sashelp.class;
quit;
%macro demo;
%do i=1 %to 10;
%put name&i=&&name&i;
View sas_export_excel_file_proc_export
/*Sample code that demonstrates how to export an excel file using SAS UE*/
proc export data=sashelp.class outfile='/folders/myfolders/Class.XLSX' dbms=xlsx replace; run;
View sas_random_number
/*How to create 50 random numbers for every observation in your data set */
data want;
set sashelp.class;
do i=1 to 50;
zv = rannor(0);
output;
end;
View sas_split_data_number_records
*create a sample data set;
data have;
do i=1 to 7000;
x=rand('bernoulli', 0.4);
output;
end;
run;
*Set group size;
%let group_size = 1000;