When a user wants to run multiple files through the same data steps, the use of wild cards can save on the number of commands required to process those steps on each file. Below is an example of reading and processing multiple files using standard coding.
options linesize=70 pagesize=52 noovp compress=yes;
filename raw68 PIPE 'zcat
/usr/data/public/us/government/cps/october/uniform/1968.Z';
filename raw69 PIPE 'zcat
/usr/data/public/us/government/cps/october/uniform/1969.Z';
data temp68;
infile raw68 lrecl=283;
input
yr 15-16
age 26-27
state 56-57
yrenr 86-87;
if yrenr ne 20 then delete;
proc freq;
tables age;
data temp69;
infile raw69 lrecl=283;
input
yr 15-16
age 26-27
state 56-57
yrenr 86-87;
if yrenr ne 20 then delete;
proc freq;
tables age;
run;
The use of wildcard characters allows the system to identify files using pattern matching. The following program will read and process the same data in fewer steps. Note the wildcard characters (?) in bold. Each wild character '?' is representative of any possible character (i.e., four wild characters '????' symbolizes any four letter file.)
options linesize=70 pagesize=52 noovp compress=yes;
filename rawall PIPE 'zcat
/usr/data/public/us/government/cps/october/uniform/19??.Z';
data tempall;
infile rawall lrecl=283;
input
yr 15-16
age 26-27
state 56-57
yrenr 86-87;
if yrenr ne 20 then delete;
proc freq;
tables age;
run;
A different wild card character that is very useful is the asterick (*). This behaves differently from the wild '?' character. You do not have to have an asterick for every character you are trying to match with. The asterick can represent a single character or a string of characters. Below are a few examples showing how the wild (*) can be used.
filename rawall PIPE 'zcat /usr/..../uniform/19*.Z';In the command line above every file that begins with the characters '19' and has the .Z extention will match the file pattern.
filename rawall PIPE 'zcat /usr/..../uniform/*90*';
Here, every filename containing the '90' string matches this pattern.
Recent resources, events, news
Farley. "Kerner Report plus 40 Years." PSC Research Report.
Galea et al. "Longitudinal Predictors of Post-traumatic Stress"
Monday, Oct 13
Jamie Jones
"Fertility & Risk Aversion on Utah Frontier"
W A R N I N G
If you are reading this, it may be that you are using rather old web browsing software that does not support modern international Web technology standards. For a better experience of the Web and this site in particular, please upgrade your web browser software today. The following are good choices: Firefox 2; Opera 9; Safari 3.