This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*This is an example of how to create an Other category for everything except the top 3*/ | |
*not ideal, other becomes first format - will look into how to make it last value; | |
*get counts; | |
proc freq data=sashelp.class order = freq; | |
table age / out=counts; | |
run; | |
*create format; | |
data counts_fmt; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data char_num; | |
char = "8.4"; output; | |
char = "10.5"; output; | |
run; | |
data char_date; | |
char = "2012-01-01";output; | |
char = "2014-02-08"; output; | |
run; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*How to selectively filter your list of variables in a SAS data set with a pattern but not one that uses SAS variable shortcuts; | |
options mprint symbolgen; | |
%macro select(lib =, ds_in=, pattern=, ds_out=); | |
proc sql noprint; | |
select nliteral(name) into :var_list separated by ' ' | |
from dictionary.columns | |
where libname = upcase("&lib") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*This macro will export a file to a data set and split it based on the number of records per sheet; | |
%macro export_split (dsn=, size=); | |
%*Get number of records and calculate the number of files needed; | |
data _null_; | |
set &dsn. nobs=_nobs; | |
call symputx('nrecs', _nobs); | |
n_files=ceil(_nobs/ &size.); | |
call symputx('nfiles', n_files); | |
stop; | |
run; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*This program illustrates how to age standardize rates using the age data for Canada 1991*/ | |
*Source Data:http://www.apheo.ca/resources/indicators/Standardization%20report_NamBains_FINALMarch16.pdf | |
*Source Code:http://support.sas.com/documentation/cdl/en/statug/65328/HTML/default/viewer.htm#statug_stdrate_syntax01.htm | |
; | |
*Create dataset with Canada Standard Rates for 1991; | |
data CanadaSTDRATE; | |
format AgeGroup 2. AgeGroupDesc $5. Canada1991 comma12.; | |
informat Canada1991 comma12.; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Author: Jeff Myers | |
Source: https://communities.sas.com/t5/Graphics-Programming/Sankey-Diagram-Decision-Tree-etc/m-p/719812# | |
*/ | |
data random; | |
call streaminit(123); | |
do id = 1 to 100; | |
do cycle=1 to 5; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
options noxwait noxsync; | |
data _null_; | |
*Path to winzip program; | |
zipexe='"C:\Program Files\7-Zip\7z.exe" a -tzip'; | |
*Zip file name; | |
zipfile="C:\My Documents\Sample.zip"; | |
*File to be zipped; | |
file="C:\Temp\Sample.txt"; | |
*Full cmd line to be passed to command line. It embeds the quotes for paths with spaces; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*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: | |
http://support.sas.com/kb/43/496.html | |
Modified to convert XLSX to CSV. | |
Author:F. Khurshed | |
Date: 2018-03-23 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*Author: F.Khurshed | |
Date: 2022-10-07*/ | |
*create library to store format catalog; | |
libname demo '/home/fkhurshed/Demo1'; | |
proc format; | |
value age_fmt | |
low - 12 = 'Child' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*This Loops thoough a set of variables where the variables | |
are separated by "|". Any other delimiter can be used | |
and specified in the scan function as well*/ | |
%macro loop(varlist); | |
%let i=1; | |
%do %while (%scan(&varlist, &i, |) ^=%str()); | |
%let var=%scan(&varlist, &i, |); | |
%put &var; |