This file contains hidden or 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 ordinal_format; | |
length label $8.; | |
do number=1 to 300; | |
numstring = put(number, 16. -l); | |
if prxmatch('/(?<!1)1\s*$/',numstring) then ending='st'; | |
else if prxmatch('/(?<!1)2\s*$/',numstring) then ending='nd'; | |
else if prxmatch('/(?<!1)3\s*$/',numstring) then ending='rd'; | |
else ending = 'th'; | |
ordstring =catt(numstring, ending); |
This file contains hidden or 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 import_all; | |
*make sure variables to store file name are long enough; | |
length filename txt_file_name $256; | |
*keep file name from record to record; | |
retain txt_file_name; | |
*Use wildcard in input; | |
infile "Path\*.txt" eov=eov filename=filename truncover; |
This file contains hidden or 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
%macro sum_missing(libname, dsetin, dsetout); | |
*Delete old dataset; | |
proc datasets nodetails nolist; | |
delete &dsetout; | |
quit; | |
*Upcase all macro variables to have consistency; | |
data _null_; | |
call symput ("libname", upcase("&libname.")); | |
call symput ("dsetin", upcase("&dsetin.")); |
This file contains hidden or 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 requires Adobe Acrobat Professional | |
List files to append in order | |
******************************************************************; | |
Data Files2Append; | |
length file $256.; | |
file="C:\Test\Sample_out.PDF"; output; | |
file="C:\Test\Sample_out 2.PDF"; output; | |
run; |
This file contains hidden or 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
%macro compare_data(base=, compare=); | |
proc sql noprint; | |
create table base_in as | |
select name | |
from sashelp.vcolumn | |
where libname=upper(scan("&base", 1, ".")) | |
and memname=upper(scan("&base", 2, ".")) | |
order by varnum; | |
quit; |
This file contains hidden or 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
*valid in SAS 9.3+, using the dynamic variable _byval_ that is automatically created by SAS; | |
proc template; | |
define statgraph scatter; | |
dynamic _x _y _byval_; | |
begingraph; | |
entrytitle "Scatter Plot of " _x " by " _y " for Sex = " _byval_; | |
layout overlay; | |
scatterplot x=_x y=_y; |
This file contains hidden or 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 calculate a moving min/max with a window of 4. | |
Resets by group ID | |
https://communities.sas.com/message/244232 | |
Courtesy of PGStats | |
*/ | |
data want; | |
array p{0:3} _temporary_; | |
set have; by object; |
This file contains hidden or 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
/* | |
Description: Creates a One-Way Freq table of variables including percent/count | |
Parameters: | |
dsetin - inputdataset | |
varlist - list of variables to be analyzed separated by spaces | |
dsetout - name of dataset to be created | |
Author: F.Khurshed | |
Date: November 2011 |
This file contains hidden or 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 spit a data set into multiple csv files each with a header row | |
and the data row that meets the condition of a group. If you want a record for each row use a unique identifier | |
as your var_split. | |
Note that this may not work if you have a very large data set that cannot be sorted or the number of variables are | |
over 150ish | |
*/ | |
*name of the data set with the original data; | |
%let lib_name = sashelp; |
This file contains hidden or 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
*Create label data set; | |
data label_data_set; | |
length name label $25.; | |
name="Sex"; label="Gender"; output; | |
name="height"; label="Height (in)"; output; | |
name="weight"; label="Weight (lbs)"; output; | |
run; | |
*Create sample dataset to apply label; |