The following statements use the DROP statement to exclude certain time series from the SAS data set. (You can also use the KEEP statement to include certain series in the SAS data set.)
options validvarname=any; %let FAME=%sysget(FAME); %put(&FAME); %let FAMETEMP=%sysget(FAME_TEMP); %put(&FAMETEMP); libname famedir sasefame "%sysget(FAME_DATA)" convert=(freq=annual technique=constant); libname mydir "%sysget(FAME_TEMP)"; data mydir.a; /* add data set to mydir */ set famedir.oecd1; drop 'ita.dirdes'n--'jpn.herd'n 'tur.dirdes'n--'usa.herd'n; where date between '01jan88'd and '31dec93'd; run; title1 "OECD1: TECH=Constant, FREQ=Annual"; title2 "Drop Using N-literals"; proc print data=mydir.a; run;
Output 40.3.1 shows the results.
OECD1: TECH=Constant, FREQ=Annual |
Drop Using N-literals |
Obs | DATE | AUS.DIRDES | AUS.HERD | AUT.DIRDES | AUT.HERD | BEL.DIRDES | BEL.HERD | CAN.DIRDES | CAN.HERD | CHE.DIRDES | CHE.HERD | DEU.DIRDES | DEU.HERD | DNK.DIRDES | DNK.HERD | ESP.DIRDES | ESP.HERD | FIN.DIRDES | FIN.HERD | FRA.DIRDES | FRA.HERD | GBR.DIRDES | GBR.HERD | GRC.DIRDES | GRC.HERD | IRL.DIRDES | IRL.HERD | ISL.DIRDES | ISL.HERD | NLD.DIRDES | NLD.HERD | NOR.DIRDES | NOR.HERD | NZL.DIRDES | NZL.HERD | PRT.DIRDES | PRT.HERD | SWE.DIRDES | SWE.HERD | YUG.DIRDES | YUG.HERD |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | 1988 | 750 | 1072.90 | . | . | 374 | 16572.70 | 1589.60 | 2006 | 632.100 | 1532 | 3538.60 | 8780.00 | 258.100 | 2662 | 508.200 | 55365.5 | 247.700 | 1602.0 | 2573.50 | 19272.00 | 2627.00 | 1592.00 | 60.600 | 6674.50 | 49.6000 | 37.0730 | . | . | 883 | 2105 | . | . | . | . | 111.5 | 10158.20 | . | . | 233.000 | 29.81 |
2 | 1989 | . | . | . | . | . | 18310.70 | 1737.00 | 2214 | . | 1648 | 3777.20 | 9226.60 | 284.800 | 2951 | 623.600 | 69270.5 | 259.700 | 1725.5 | 2856.50 | 21347.80 | 2844.10 | 1774.20 | 119.800 | 14485.20 | 50.2000 | 39.0130 | 10.3000 | 786.762 | 945 | 2202 | 308.900 | 2771.40 | 78.7000 | 143.800 | . | . | 1076 | 11104 | 205.100 | 375.22 |
3 | 1990 | . | . | . | . | . | 18874.20 | 1859.20 | 2347 | . | . | 2953.30 | 9700.00 | . | . | 723.600 | 78848.0 | 271.000 | 1839.0 | 3005.20 | 22240.00 | . | . | . | . | 51.7000 | . | 11.0000 | 902.498 | . | . | . | . | . | . | . | . | . | . | . | 2588.50 |
4 | 1991 | . | . | . | . | . | . | 1959.60 | 2488 | . | . | . | . | . | . | . | 89908.0 | . | . | . | . | . | . | . | . | . | . | 11.8000 | 990.865 | . | . | 352.000 | 3100.00 | . | . | . | . | . | . | . | . |
Note that the SAS option VALIDVARNAME=ANY was used at the beginning of this example because special characters are present in the time series names. SAS variables that contain certain special characters are called n-literals and are referenced in SAS code as shown in this example.
You can rename your SAS variables by using the RENAME statement. The following statements show how to use n-literals when selecting variables you want to keep, and how to rename some of your kept variables:
options validvarname=any; %let FAME=%sysget(FAME); %put(&FAME); %let FAMETEMP=%sysget(FAME_TEMP); %put(&FAMETEMP); libname famedir sasefame "%sysget(FAME_DATA)" convert=(freq=annual technique=constant); libname mydir "%sysget(FAME_TEMP)"; data mydir.a; /* add data set to mydir */ set famedir.oecd1; /* keep and rename */ keep date 'ita.dirdes'n--'jpn.herd'n 'tur.dirdes'n--'usa.herd'n; rename 'ita.dirdes'n='italy.dirdes'n 'jpn.dirdes'n='japan.dirdes'n 'tur.dirdes'n='turkey.dirdes'n 'usa.dirdes'n='united.states.of.america.dirdes'n ; run; title1 "OECD1: TECH=Constant, FREQ=Annual"; title2 "keep statement using n-literals"; title3 "rename statement using n-literals"; proc print data=mydir.a; run;
Output 40.3.2 shows the results.
OECD1: TECH=Constant, FREQ=Annual |
keep statement using n-literals |
rename statement using n-literals |
Obs | DATE | italy.dirdes | ITA.HERD | japan.dirdes | JPN.HERD | turkey.dirdes | TUR.HERD | united.states.of.america.dirdes | USA.HERD |
---|---|---|---|---|---|---|---|---|---|
1 | 1985 | 1344.90 | 1751008 | 8065.70 | 1789780 | 144.800 | 22196 | 14786.00 | 14786.00 |
2 | 1986 | 1460.60 | 2004453 | 8290.10 | 1832575 | 136.400 | 26957 | 16566.90 | 16566.90 |
3 | 1987 | 1674.40 | 2362102 | 9120.80 | 1957921 | 121.900 | 32309 | 18326.10 | 18326.10 |
4 | 1988 | 1861.50 | 2699927 | 9657.20 | 2014073 | 174.400 | 74474 | 20246.20 | 20246.20 |
5 | 1989 | 1968.00 | 2923504 | 10405.90 | 2129372 | 212.300 | 143951 | 22159.50 | 22159.50 |
6 | 1990 | 2075.00 | 3183071 | . | 2296992 | . | . | 23556.10 | 23556.10 |
7 | 1991 | 2137.80 | 3374000 | . | . | . | . | 24953.80 | 24953.80 |