These test packs do not test the macros thoroughly. They are there to give you a start for testing them yourself with an aim to validating the macros.
All the code members below assume that you have already assigned the Spectre macro library to your sasautos path.
Test code:
options nocenter ls=64 formdlim="_";
proc format; value numfmt 1="One" 9="Nine" 6="Six" 3="Three" 12="Twelve" ; value $cntry "UK"="United Kingdom" "AU"="Australia" "NZ"="New Zealand" "NG"="New Guinea" ; run; %allfmtvals(fmt=numfmt.,dsout=dsnum1,var=num)
%allfmtvals(fmt=numfmt.,dsout=dsnum2,var=num,decodevar=numstr,decodelen=8)
%allfmtvals(fmt=$cntry,dsout=cntry1,length=2,var=country)
%allfmtvals(fmt=$cntry,dsout=cntry2,length=2,var=country,decodevar=cntrystr,decodelen=6)
|
lst:
dsnum1 with format cancelled for num
Obs num 1 1
__________________________________________________________________________________________________ dsnum1 with format applied to num Obs num 1 One
__________________________________________________________________________________________________ dsnum2 with format applied to num Obs numstr num 1 One
One
__________________________________________________________________________________________________ cntry1 with format cancelled for country Obs country 1 AU
__________________________________________________________________________________________________ cntry1 with format applied for country Obs country 1 Australia
__________________________________________________________________________________________________ cntry2 with format cancelled for country Obs cntrystr country 1 Austra
AU
|
Test code:
data test;
dummy='dummy'; num=2; output; num=1; output; num=3; output; run; %put >>>> creation datetime stamp (should be just now) is "%sysfunc(putn(%attrn(test,crdte),datetime.))"
>>>>;
|
log:
70
71 %put >>>> creation datetime stamp (should be just now) is 71 ! "%sysfunc(putn(%attrn(test,crdte),datetime.))" >>>>; >>>> creation datetime stamp (should be just now) is "10MAY06:08:47:25" >>>> 72 %put >>>> modification datetime stamp (should be just now) is 72 ! "%sysfunc(putn(%attrn(test,modte),datetime.))" >>>>; >>>> modification datetime stamp (should be just now) is "10MAY06:08:47:25" >>>> 73 %put >>>> number of observations (should be 3) is "%attrn(test,nobs)" >>>>; >>>> number of observations (should be 3) is "3" >>>>
>>>> number of logical observations (should be 3) is "3" >>>>
>>>> number of dataset variables (should be 2) is "2" >>>> |
Test code:
data test;
length dummy $ 16; dummy='dummy'; num=2; attrib dummy format=$char16. num format=5. informat=3. label='a number'; run; %put >>>> type of "dummy" var (should be "C") is "%attrv(test,dummy,vartype)"
>>>>;
%put >>>> type of "num" var (should be "N") is "%attrv(test,num,vartype)"
>>>>;
|
log:
118
119 %put >>>> type of "dummy" var (should be "C") is "%attrv(test,dummy,vartype)" >>>>; >>>> type of "dummy" var (should be "C") is "C" >>>>
>>>> length of "dummy" var (should be "16") is "16" >>>>
>>>> label of "dummy" var (should be "") is "" >>>>
>>>> informat of "dummy" var (should be "") is "" >>>>
>>>> type of "num" var (should be "N") is "N" >>>>
>>>> length of "num" var (should be "8") is "8" >>>>
>>>> label of "num" var (should be "a number") is "a number" >>>>
>>>> format of "num" var (should be "5.") is "5." >>>>
>>>> informat of "num" var (should be "3.") is "3." >>>> |
Test code:
%let varlist = aa bb cc_cc DD _eee f g;
%put (should be >>>> aa, bb, cc_cc, DD, _eee, f, g >>>>); %put >>>> %commas(&varlist) >>>>; |
log:
130 %let varlist = aa bb cc_cc DD _eee f g;
131 %put (should be >>>> aa, bb, cc_cc, DD, _eee, f, g >>>>); (should be >>>> aa, bb, cc_cc, DD, _eee, f, g >>>>) 132 %put >>>> %commas(&varlist) >>>>; >>>> aa, bb, cc_cc, DD, _eee, f, g >>>> |
Test code:
options nocenter formdlim="_";
title1; proc format; value racecd 1="Caucasian" 2="Black" 3="Hispanic" 4="Asian" 5="Unknown" ; value $cntry "A"="United Kingdom" "B"="Australia" "C"="New Zealand" "D"="New Guinea" ; run; %fmtord(racecd) data test1;
%fmtord($cntry) data test2;
|
lst:
Obs race
ord
1 Other
.
__________________________________________________________________________________________________ Obs cntry ord 1 No Such Country
.
|
Test code:
%put should be >>>> WORK.FORMATS LIBRARY.FORMATS >>>>;
%put >>> %fmtpath >>>>; options fmtsearch=(one two work three);
options fmtsearch=(one.fmtcat two);
options fmtsearch=(local);
options fmtsearch=(work);
|
log:
1 %put should be >>>> WORK.FORMATS LIBRARY.FORMATS
>>>>;
should be >>>> WORK.FORMATS LIBRARY.FORMATS >>>> 2 %put >>> %fmtpath >>>>; >>> WORK.FORMATS LIBRARY.FORMATS >>>> 3 4 options fmtsearch=(one two work three); 5 %put should be >>>> LIBRARY.FORMATS ONE.FORMATS TWO.FORMATS WORK.FORMATS THREE.FORMATS >>>>; should be >>>> LIBRARY.FORMATS ONE.FORMATS TWO.FORMATS WORK.FORMATS
THREE.FORMATS >>>>
should be >>>> WORK.FORMATS LIBRARY.FORMATS ONE.FMTCAT TWO.FORMATS
>>>>
|
Test code:
%let varlist=VARA VARB VARC;
%put should be >>>> "VARA" "VARB" "VARC" >>>>;
%let varlist=; %put should be >>>> >>>>;
|
log:
27 %let varlist=VARA VARB VARC;
28 29 %put should be >>>> "VARA" "VARB" "VARC" >>>>; should be >>>> "VARA" "VARB" "VARC" >>>> 30 %put >>>> %quotelst(&varlist) >>>>; >>>> "VARA" "VARB" "VARC" >>>> 31 32 %let varlist=; 33 34 %put should be >>>> >>>>; should be >>>> >>>> 35 %put >>>> %quotelst(&varlist) >>>>; >>>> >>>> |
Test code:
%let str=display flow 'Display' 'label' left;
%put should be >>> display 'Display' 'label' >>;
%put should be >>> flow '' 'label' left >>;
%put should be >>> display flow '' 'label' left >>;
|
log:
107 %let str=display flow 'Display' 'label' left;
108 109 %put should be >>> display 'Display' 'label' >>; should be >>> display 'Display' 'label' >> 110 %put >>> %remove(&str,left,Flow) >>; >>> display 'Display' 'label' >> 111 112 %put should be >>> flow '' 'label' left >>; should be >>> flow '' 'label' left >> 113 %put >>> %remove(&str,display) >>; >>> flow '' 'label' left >> 114 115 %put should be >>> display flow '' 'label' left >>; should be >>> display flow '' 'label' left >> 116 %put >>> %remove(&str,Display,casesens=yes) >>; >>> display flow '' 'label' left >> |
Test code:
%put should be MIN MEAN MAX STD MEDIAN ;
%put %unimap(Minimum Mean° Maximum S.D. Median*); |
log:
38 %put should be MIN MEAN MAX STD MEDIAN ;
should be MIN MEAN MAX STD MEDIAN 39 %put %unimap(Minimum Mean° Maximum S.D. Median*); MIN MEAN MAX STD MEDIAN |
Test code:
data test;
length dummy $ 16; dummy='dummy'; num=2; attrib dummy format=$char16. num format=5. informat=3. label='a number'; run; %put >>>> format of "dummy" var (should be "$CHAR16.") is "%varfmt(test,dummy)"
>>>>;
|
log:
47 %put >>>> format of "dummy" var (should be
"$CHAR16.") is "%varfmt(test,dummy)" >>>>;
>>>> format of "dummy" var (should be "$CHAR16.") is "$CHAR16."
>>>>
>>>> format of "num" var (should be "5.") is "5." >>>> |
Test code:
data test;
length dummy $ 16; dummy='dummy'; num=2; attrib dummy format=$char16. num format=5. informat=3. label='a number'; run; %put >>>> length of "dummy" var (should be "$ 16") is "%varlen(test,dummy)"
>>>>;
%put >>>> length of "num" var (should be "8") is "%varlen(test,num)"
>>>>;
|
log:
56 %put >>>> length of "dummy" var (should be
"$ 16") is "%varlen(test,dummy)" >>>>;
>>>> length of "dummy" var (should be "$ 16") is "$ 16" >>>>
>>>> same again but no dollar (should be "16") is "16" >>>>
>>>> length of "num" var (should be "8") is "8" >>>>
|
Test code:
data test;
length dummy $ 16; num=1; dummy='dummy'; num2=2; char3='3'; run; %put >>>> position of "dummy" var (should be 1) is %varnum(test,dummy)
>>>>;
|
log:
81 %put >>>> position of "dummy" var (should
be 1) is %varnum(test,dummy) >>>>;
>>>> position of "dummy" var (should be 1) is 1 >>>>
>>>> position of "num2" var (should be 3) is 3 >>>>
>>>> position of "char3" var (should be 4) is 4 >>>>
>>>> position of non-existent var "roland" (should be 0) is 0 >>>
|
Test code:
data test;
length dummy $ 16; dummy='dummy'; num=2; attrib dummy format=$char16. num format=5. informat=3. label='a number'; run; %put >>>> type of "dummy" var (should be "C") is "%vartype(test,dummy)"
>>>>;
|
log:
95 %put >>>> type of "dummy" var (should be "C")
is "%vartype(test,dummy)" >>>>;
>>>> type of "dummy" var (should be "C") is "C" >>>>
>>>> type of "num" var (should be "N") is "N" >>>> |
Test code:
%let str=%str(xyz aa bb ccx
);
%put >>> (should be 15) is %verifyb(&str,%str( abc)) >>>; %let str=%str(bbccaa a b c );
%let str=;
%let str=Z;
|
log:
169 %let str=%str(xyz aa bb ccx
);
170 %put >>> (should be 15) is %verifyb(&str,%str( abc)) >>>; >>> (should be 15) is 15 >>> 171 172 %let str=%str(bbccaa a b c ); 173 %put >>> (should be 0) is %verifyb(&str,%str( abc)) >>>; >>> (should be 0) is 0 >>> 174 175 %let str=; 176 %put >>> (should ERROR) is %verifyb(&str,%str( abc)) >>>; ERROR: (verifyb) No text string supplied for verifyb to act on. ERROR: (verifyb) Leaving macro due to error(s) listed. >>> (should ERROR) is >>> 177 178 %let str=Z; 179 %put >>> (should be 1) is %verifyb(&str,%str( abc)) >>>; >>> (should be 1) is 1 >>> |
Test code:
%let days=sunday monday tuesday wednesday thursday;
%put >>> (should be 3) %windex(&days,tuesday) >>>;
|
log:
180 %let days=sunday monday tuesday wednesday thursday;
181 182 %put >>> (should be 3) %windex(&days,tuesday) >>>; >>> (should be 3) 3 >>> 183 %put >>> (should be 0) %windex(&days,TUESDAY) >>>; >>> (should be 0) 0 >>> 184 %put >>> (should be 0) %windex(&days,tues) >>>; >>> (should be 0) 0 >>> 185 %put >>> (should be 0) %windex(&days,ZZ) >>>; >>> (should be 0) 0 >>> |
Test code:
%let days=sunday monday tuesday wednesday thursday friday saturday;
%put >>> Number of days (should be 7) is %words(&days) >>>; %let null=;
%let repeat=repeat repeat;
|
log:
117 %let days=sunday monday tuesday wednesday thursday friday
saturday;
118 %put >>> Number of days (should be 7) is %words(&days) >>>; >>> Number of days (should be 7) is 7 >>> 119 120 %let null=; 121 %put >>> Number of words in null string (should be 0) is %words(&null) >>>; >>> Number of words in null string (should be 0) is 0 >>>
>>> Number of words in repeat string (should be 2) is 2 >>> |
Test code:
options nocenter formdlim="_" ls=64;
title1; data tmt;
data subj;
%zerogrid(zerovar=count,var1=tmtarm,ds1=tmt,var2=subject,ds2=subj)
%zerogrid(zerovar=count,var1=tmtarm,ds1=tmt,var2=subject,ds2=subj,
%zerogrid(zerovar=_str,zero=" 0 ( 0.0)",var1=tmtarm,ds1=tmt,var2=subject,ds2=subj,
|
lst:
simple case that will be in tmtarm/subject order
Obs count tmtarm subject 1 0
A 1234
________________________________________________________________ same again but output order changed to subject/tmtarm order Obs count tmtarm subject 1 0
A 1234
________________________________________________________________ same as before but zerovar and zero value changed Obs _str tmtarm subject 1 0 ( 0.0)
A 1234
|
Use the "Back" button of your browser to return to the previous page
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration.
Global View of
should and
and also
put
The Fastest
FTPS
on the planet
FREE Go FTP
Client