SASEBLS Interface Engine
Example 23.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 IDs of the time series to be retrieved 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 the ID of each series 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 to retrieve using their IDs. 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. The FORMAT= option specifies that the data are to be retrieved using the JSON format. Output 23.5.1 shows the data that are retrieved. Output 23.5.2 shows the catalog information for the retrieved data.
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
CATALOG=true
FORMAT=json;
data myCES;
set bls.blsex05 ;
run;
proc print data=myCES; run;
Output 23.5.1: All Seasonally Adjusted Nonfarm 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 | 130579 | 109 | -42 | -4 | -273 | 0.1 | 0.0 | 0.0 | -0.2 | 107019 | -2266 | -2633 | -2870 | -558 | -2.1 | -2.4 | -2.6 | -0.5 |
| 2 | 2003 | M02 | February | 130443 | -136 | -175 | -144 | -289 | -0.1 | -0.1 | -0.1 | -0.2 | 107052 | 33 | -2583 | -2893 | -584 | 0.0 | -2.4 | -2.6 | -0.5 |
| 3 | 2003 | M03 | March | 130233 | -210 | -237 | -265 | -488 | -0.2 | -0.2 | -0.2 | -0.4 | 107457 | 405 | -1828 | -2037 | -662 | 0.4 | -1.7 | -1.9 | -0.6 |
| 4 | 2003 | M04 | April | 130176 | -57 | -403 | -445 | -441 | 0.0 | -0.3 | -0.3 | -0.3 | 108131 | 674 | 1112 | -1521 | -566 | 0.6 | 1.0 | -1.4 | -0.5 |
| 5 | 2003 | M05 | May | 130197 | 21 | -246 | -421 | -436 | 0.0 | -0.2 | -0.3 | -0.3 | 108906 | 775 | 1854 | -729 | -461 | 0.7 | 1.7 | -0.7 | -0.4 |
| 6 | 2003 | M06 | June | 130192 | -5 | -41 | -278 | -491 | 0.0 | 0.0 | -0.2 | -0.4 | 109634 | 728 | 2177 | 349 | -519 | 0.7 | 2.0 | 0.3 | -0.5 |
| 7 | 2003 | M07 | July | 130183 | -9 | 7 | -396 | -400 | 0.0 | 0.0 | -0.3 | -0.3 | 109438 | -196 | 1307 | 2419 | -451 | -0.2 | 1.2 | 2.3 | -0.4 |
| 8 | 2003 | M08 | August | 130153 | -30 | -44 | -290 | -434 | 0.0 | 0.0 | -0.2 | -0.3 | 109533 | 95 | 627 | 2481 | -412 | 0.1 | 0.6 | 2.3 | -0.4 |
| 9 | 2003 | M09 | September | 130252 | 99 | 60 | 19 | -246 | 0.1 | 0.0 | 0.0 | -0.2 | 109262 | -271 | -372 | 1805 | -232 | -0.2 | -0.3 | 1.7 | -0.2 |
| 10 | 2003 | M10 | October | 130439 | 187 | 256 | 263 | -182 | 0.1 | 0.2 | 0.2 | -0.1 | 109512 | 250 | 74 | 1381 | -140 | 0.2 | 0.1 | 1.3 | -0.1 |
| 11 | 2003 | M11 | November | 130482 | 43 | 329 | 285 | -136 | 0.0 | 0.3 | 0.2 | -0.1 | 109569 | 57 | 36 | 663 | -66 | 0.1 | 0.0 | 0.6 | -0.1 |
| 12 | 2003 | M12 | December | 130595 | 113 | 343 | 403 | 125 | 0.1 | 0.3 | 0.3 | 0.1 | 109454 | -115 | 192 | -180 | 169 | -0.1 | 0.2 | -0.2 | 0.2 |
| 13 | 2004 | M01 | January | 130765 | 170 | 326 | 582 | 186 | 0.1 | 0.2 | 0.4 | 0.1 | 107266 | -2188 | -2246 | -2172 | 247 | -2.0 | -2.1 | -2.0 | 0.2 |
| 14 | 2004 | M02 | February | 130822 | 57 | 340 | 669 | 379 | 0.0 | 0.3 | 0.5 | 0.3 | 107474 | 208 | -2095 | -2059 | 422 | 0.2 | -1.9 | -1.9 | 0.4 |
| 15 | 2004 | M03 | March | 131139 | 317 | 544 | 887 | 906 | 0.2 | 0.4 | 0.7 | 0.7 | 108369 | 895 | -1085 | -893 | 912 | 0.8 | -1.0 | -0.8 | 0.8 |
| 16 | 2004 | M04 | April | 131410 | 271 | 645 | 971 | 1234 | 0.2 | 0.5 | 0.7 | 0.9 | 109468 | 1099 | 2202 | -44 | 1337 | 1.0 | 2.1 | 0.0 | 1.2 |
| 17 | 2004 | M05 | May | 131694 | 284 | 872 | 1212 | 1497 | 0.2 | 0.7 | 0.9 | 1.1 | 110392 | 924 | 2918 | 823 | 1486 | 0.8 | 2.7 | 0.8 | 1.4 |
| 18 | 2004 | M06 | June | 131789 | 95 | 650 | 1194 | 1597 | 0.1 | 0.5 | 0.9 | 1.2 | 111280 | 888 | 2911 | 1826 | 1646 | 0.8 | 2.7 | 1.7 | 1.5 |
| 19 | 2004 | M07 | July | 131849 | 60 | 439 | 1084 | 1666 | 0.0 | 0.3 | 0.8 | 1.3 | 111231 | -49 | 1763 | 3965 | 1793 | 0.0 | 1.6 | 3.7 | 1.6 |
| 20 | 2004 | M08 | August | 131936 | 87 | 242 | 1114 | 1783 | 0.1 | 0.2 | 0.9 | 1.4 | 111232 | 1 | 840 | 3758 | 1699 | 0.0 | 0.8 | 3.5 | 1.6 |
| 21 | 2004 | M09 | September | 132082 | 146 | 293 | 943 | 1830 | 0.1 | 0.2 | 0.7 | 1.4 | 110901 | -331 | -379 | 2532 | 1639 | -0.3 | -0.3 | 2.3 | 1.5 |
| 22 | 2004 | M10 | October | 132433 | 351 | 584 | 1023 | 1994 | 0.3 | 0.4 | 0.8 | 1.5 | 111357 | 456 | 126 | 1889 | 1845 | 0.4 | 0.1 | 1.7 | 1.7 |
| 23 | 2004 | M11 | November | 132509 | 76 | 573 | 815 | 2027 | 0.1 | 0.4 | 0.6 | 1.6 | 111457 | 100 | 225 | 1065 | 1888 | 0.1 | 0.2 | 1.0 | 1.7 |
| 24 | 2004 | M12 | December | 132633 | 124 | 551 | 844 | 2038 | 0.1 | 0.4 | 0.6 | 1.6 | 111349 | -108 | 448 | 69 | 1895 | -0.1 | 0.4 | 0.1 | 1.7 |
The following statements print the catalog information shown in Output 23.5.2:
libname blscat "%sysget(BLS)";
data myCAT;
set blscat.blsex05_catalog;
run;
proc print data=myCAT; run;
Output 23.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 |