The SASEBLS Interface Engine
Example 20.5 Retrieving Current Employment Statistics National Survey (CE) Data
This example shows how to retrieve data from the Current Employment Statistics Survey (CE). You can view these data by using the following URL:
https://www.bls.gov/ces/data/
INSERIES is an input SAS data set that lists the time series IDs to be read from the Current Employment Statistics (CES) database. In this example, the input SAS data set is named in the INSET=INSERIES option. To create the INSERIES data set, use the DATA step. In the DATA statement, the name of the input data set is specified as 'INSERIES'. Next, the length of the series ID is specified as 32 bytes prior to listing each series ID to be accessed. Each time series is listed on its own line, along with the OUTPUT statement. When the series IDs have been listed, the DATA step is ended with a RUN statement. The following SASEBLS LIBNAME statement specifies the libref (BLS), followed by the engine name (SASEBLS) and the physical path where the retrieved BLS data are to be stored. The OUTJSON= option names the file where the JSON data are stored. The output data set is created using the OUTJSON= option and placed in the folder that is specified in the SASEBLS LIBNAME statement. The INSET= option specifies the INSERIES data set for the list of series IDs to retrieve. In this example, two time series, CES0000000001 and CEU0500000001, are requested, along with any calculations. Both time series have 1-month, 3-month, 6-month, and 12-month net and percentage changes.
The date range of the data starts with 2003, as specified by the STARTYEAR= option. The ENDYEAR= option specifies the last year, 2004, to include in the range of data to retrieve. The FREQ=MONTH option specifies the selection of monthly data, but because the CALCULATIONS=TRUE option is specified, the retrieved data also include the net change calculation and percentage change calculation statistics. Because the ANNUALAVERAGE=TRUE option is specified, the output should include the annual average M13 data, but in this example only one of the requested time series, CEU0500000001, has data for the M13 frequency. The FORMAT= option specifies that the data are to be retrieved using the JSON format. Output 20.5.1 shows the data that are retrieved.
options;
DATA inseries;
length seriesid $ 32;
seriesid = 'CES0000000001'; output; /* All employees */
seriesid = 'CEU0500000001'; output;
RUN;
title 'Retrieve Current Employment Statistics Data';
libname bls sasebls "%sysget(BLS)"
USER='XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
SETNAME=CES
INSET=inseries
PAYPATH= "%sysget(BLS)payload"
OUTJSON=blsex05
STARTYEAR='2003'
ENDYEAR='2004'
FREQ=Month
CALCULATIONS=true
ANNUALAVERAGE=true
CATALOG=true
FORMAT=json;
data myCES;
set bls.blsex05 ;
run;
proc print data=myCES; run;
Output 20.5.1: All Seasonally Adjusted Non-farm Employees and All Not Seasonally Adjusted Private Employees
| Retrieve Current Employment Statistics Data |
| Obs | year | period | periodName | CES0000000001 | CES0000000001_1 | CES0000000001_3 | CES0000000001_6 | CES0000000001_12 | CES0000000001%1 | CES0000000001%3 | CES0000000001%6 | CES0000000001%12 | CEU0500000001 | CEU0500000001_1 | CEU0500000001_3 | CEU0500000001_6 | CEU0500000001_12 | CEU0500000001%1 | CEU0500000001%3 | CEU0500000001%6 | CEU0500000001%12 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 2003 | M01 | January | 130580 | 108 | -48 | -10 | -272 | 0.1 | 0.0 | 0.0 | -0.2 | 107019 | -2267 | -2633 | -2869 | -557 | -2.1 | -2.4 | -2.6 | -0.5 |
| 2 | 2003 | M02 | February | 130444 | -136 | -171 | -143 | -292 | -0.1 | -0.1 | -0.1 | -0.2 | 107053 | 34 | -2582 | -2891 | -583 | 0.0 | -2.4 | -2.6 | -0.5 |
| 3 | 2003 | M03 | March | 130232 | -212 | -240 | -269 | -485 | -0.2 | -0.2 | -0.2 | -0.4 | 107457 | 404 | -1829 | -2038 | -661 | 0.4 | -1.7 | -1.9 | -0.6 |
| 4 | 2003 | M04 | April | 130177 | -55 | -403 | -451 | -446 | 0.0 | -0.3 | -0.3 | -0.3 | 108132 | 675 | 1113 | -1520 | -565 | 0.6 | 1.0 | -1.4 | -0.5 |
| 5 | 2003 | M05 | May | 130196 | 19 | -248 | -419 | -438 | 0.0 | -0.2 | -0.3 | -0.3 | 108906 | 774 | 1853 | -729 | -461 | 0.7 | 1.7 | -0.7 | -0.4 |
| 6 | 2003 | M06 | June | 130194 | -2 | -38 | -278 | -490 | 0.0 | 0.0 | -0.2 | -0.4 | 109635 | 729 | 2178 | 349 | -519 | 0.7 | 2.0 | 0.3 | -0.5 |
| 7 | 2003 | M07 | July | 130191 | -3 | 14 | -389 | -399 | 0.0 | 0.0 | -0.3 | -0.3 | 109437 | -198 | 1305 | 2418 | -451 | -0.2 | 1.2 | 2.3 | -0.4 |
| 8 | 2003 | M08 | August | 130149 | -42 | -47 | -295 | -438 | 0.0 | 0.0 | -0.2 | -0.3 | 109534 | 97 | 628 | 2481 | -410 | 0.1 | 0.6 | 2.3 | -0.4 |
| 9 | 2003 | M09 | September | 130254 | 105 | 60 | 22 | -247 | 0.1 | 0.0 | 0.0 | -0.2 | 109263 | -271 | -372 | 1806 | -232 | -0.2 | -0.3 | 1.7 | -0.2 |
| 10 | 2003 | M10 | October | 130454 | 200 | 263 | 277 | -174 | 0.2 | 0.2 | 0.2 | -0.1 | 109513 | 250 | 76 | 1381 | -139 | 0.2 | 0.1 | 1.3 | -0.1 |
| 11 | 2003 | M11 | November | 130474 | 20 | 325 | 278 | -141 | 0.0 | 0.2 | 0.2 | -0.1 | 109569 | 56 | 35 | 663 | -66 | 0.1 | 0.0 | 0.6 | -0.1 |
| 12 | 2003 | M12 | December | 130588 | 114 | 334 | 394 | 116 | 0.1 | 0.3 | 0.3 | 0.1 | 109454 | -115 | 191 | -181 | 168 | -0.1 | 0.2 | -0.2 | 0.2 |
| 13 | 2003 | M13 | Annual | 108748 | -706 | -765 | -689 | -373 | -0.6 | -0.7 | -0.6 | -0.3 | |||||||||
| 14 | 2004 | M01 | January | 130769 | 181 | 315 | 578 | 189 | 0.1 | 0.2 | 0.4 | 0.1 | 107266 | -2188 | -2247 | -2171 | 247 | -2.0 | -2.1 | -2.0 | 0.2 |
| 15 | 2004 | M02 | February | 130825 | 56 | 351 | 676 | 381 | 0.0 | 0.3 | 0.5 | 0.3 | 107474 | 208 | -2095 | -2060 | 421 | 0.2 | -1.9 | -1.9 | 0.4 |
| 16 | 2004 | M03 | March | 131142 | 317 | 554 | 888 | 910 | 0.2 | 0.4 | 0.7 | 0.7 | 108369 | 895 | -1085 | -894 | 912 | 0.8 | -1.0 | -0.8 | 0.8 |
| 17 | 2004 | M04 | April | 131411 | 269 | 642 | 957 | 1234 | 0.2 | 0.5 | 0.7 | 0.9 | 109468 | 1099 | 2202 | -45 | 1336 | 1.0 | 2.1 | 0.0 | 1.2 |
| 18 | 2004 | M05 | May | 131694 | 283 | 869 | 1220 | 1498 | 0.2 | 0.7 | 0.9 | 1.2 | 110392 | 924 | 2918 | 823 | 1486 | 0.8 | 2.7 | 0.8 | 1.4 |
| 19 | 2004 | M06 | June | 131793 | 99 | 651 | 1205 | 1599 | 0.1 | 0.5 | 0.9 | 1.2 | 111281 | 889 | 2912 | 1827 | 1646 | 0.8 | 2.7 | 1.7 | 1.5 |
| 20 | 2004 | M07 | July | 131848 | 55 | 437 | 1079 | 1657 | 0.0 | 0.3 | 0.8 | 1.3 | 111231 | -50 | 1763 | 3965 | 1794 | 0.0 | 1.6 | 3.7 | 1.6 |
| 21 | 2004 | M08 | August | 131937 | 89 | 243 | 1112 | 1788 | 0.1 | 0.2 | 0.8 | 1.4 | 111232 | 1 | 840 | 3758 | 1698 | 0.0 | 0.8 | 3.5 | 1.6 |
| 22 | 2004 | M09 | September | 132093 | 156 | 300 | 951 | 1839 | 0.1 | 0.2 | 0.7 | 1.4 | 110903 | -329 | -378 | 2534 | 1640 | -0.3 | -0.3 | 2.3 | 1.5 |
| 23 | 2004 | M10 | October | 132447 | 354 | 599 | 1036 | 1993 | 0.3 | 0.5 | 0.8 | 1.5 | 111357 | 454 | 126 | 1889 | 1844 | 0.4 | 0.1 | 1.7 | 1.7 |
| 24 | 2004 | M11 | November | 132503 | 56 | 566 | 809 | 2029 | 0.0 | 0.4 | 0.6 | 1.6 | 111458 | 101 | 226 | 1066 | 1889 | 0.1 | 0.2 | 1.0 | 1.7 |
| 25 | 2004 | M12 | December | 132624 | 121 | 531 | 831 | 2036 | 0.1 | 0.4 | 0.6 | 1.6 | 111350 | -108 | 447 | 69 | 1896 | -0.1 | 0.4 | 0.1 | 1.7 |
| 26 | 2004 | M13 | Annual | 110148 | -1202 | -1209 | -1083 | 1400 | -1.1 | -1.1 | -1.0 | 1.3 |
The following code prints the catalog information:
libname blscat "%sysget(BLS)";
data myCAT;
set blscat.blsex05_catalog;
run;
proc print data=myCAT; run;
Output 20.5.2: Catalog for Series CES0000000001 and CEU0500000001
| Retrieve Current Employment Statistics Data |
| Obs | ordinal_series | ordinal_catalog | series_title | series_id | seasonality | survey_name | survey_abbreviation | measure_data_type | commerce_industry | commerce_sector |
|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 1 | 1 | All employees, thousands, total nonfarm, seasonally adjusted | CES0000000001 | Seasonally Adjusted | Employment, Hours, and Earnings from the Current Employment Statistics survey (National) | CE | ALL EMPLOYEES, THOUSANDS | Total nonfarm | Total nonfarm |
| 2 | 2 | 2 | All employees, thousands, total private, not seasonally adjusted | CEU0500000001 | Not Seasonally Adjusted | Employment, Hours, and Earnings from the Current Employment Statistics survey (National) | CE | ALL EMPLOYEES, THOUSANDS | Total private | Total private |