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 shows an example of going from a wide format to an extra wide format. | |
| Original question: | |
| https://communities.sas.com/t5/SAS-Programming/Row-to-variable/m-p/522615/ | |
| */ | |
| *Create sample data; | |
| data have; | |
| informat Case Variable $15.; | |
| input Case $ Variable $ Y112 Y113 Y114; | |
| cards; |
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 macro splits a data set into data sets of size N. | |
| The parameters requried are: | |
| 1. DSN = input data set name, such as sashelp.cars. | |
| The libname should be included unless the data set | |
| is in the work library. | |
| 2. Size = Number of records to be included in each data | |
| set. Note that the last data set will be truncated, | |
| ie if only 28 records are available only 28 will be | |
| written to the output data set. |
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 code illustrates how to rename data sets dynamically*/ | |
| data _new_list; | |
| set sashelp.vtable | |
| (where=(upcase(libname)='WORK')) end=eof; | |
| *filter list for only tables of interest; | |
| *start proc datasets; | |
| if _n_=1 then |
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 is an example of how to export a data set with two header rows, | |
| one that is labels and oen that is the variable names | |
| */ | |
| *Create demo data; | |
| data class; | |
| set sashelp.class; | |
| label age='Age, Years' weight = 'Weight(lbs)' height='Height, inches'; | |
| 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
| /* | |
| This macro creates a table of charateristics for the variables listed. | |
| It handles categorical, binary and continuous variables and produces and output dataset that can be further customized. No statistical information is | |
| included in this analysis | |
| */ | |
| /*Parameters to be set: | |
| dsetin - name of dataset to be analyzed | |
| cont = macro variable list of variable names, ie cont=age weight height | |
| cat=list of categorical variables ie cat=sex grade |
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 is an exmaple of how to create an informat for a character variable. | |
| It converts a character variable to a numeric one as well. | |
| Author: F. Khurshed | |
| Date: 2018-11-14 | |
| */ | |
| *create format; | |
| proc format; | |
| invalue $ grade_fmt |
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 plays a Christmas Carol | |
| Not sure of original source but it was posted here: | |
| https://groups.google.com/forum/#!topic/comp.soft-sys.sas/a9lmYmTNlv8 | |
| */ | |
| data holidays; | |
| retain fmtname '@$holiday'; | |
| length data $3; |
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
| /* Find a maximum value and the date that maximum value occurred | |
| Using PROC SUMMARY to get the ID variables of statistics using MAXID and MINID statistics. | |
| Tags: MinID, MaxID, PROC SUMMARY | |
| */ | |
| *create sample data; | |
| data have; | |
| input station $ datetime anydtdtm. calculatedpower ; | |
| format datetime datetime.; | |
| cards; |
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 finds the nearest value ABOVE a set value, it could be modified to find the lowest or nearest in general | |
| Originally propsed here via F. Khurshed | |
| https://communities.sas.com/t5/SAS-Programming/Finding-Closest-Value-to-a-List-of-Values/m-p/498539 | |
| */ | |
| data t1; | |
| input value1; | |
| cards; | |
| 31 | |
| 53 |
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 | |
| A script for finding files in a directory and writing the list out to a CSV file | |
| Modified from this one | |
| #> | |
| Write-Host "Enter Root Directory you would like to search" | |
| Write-Host "" | |
| Write-Host "Example: C:\Users\testuser" |