SASEBLS Interface Engine
Example 23.7 Retrieving Labor Force Current Population Statistics (CPS) Data
This example shows how to retrieve data from the Weekly Hours and Earnings Survey, LE, and the Labor Force Statistics Survey (includes the national unemployment rate), LN, both from the Current Population Statistics program data. You can view these data by using the following URL:
https://www.bls.gov/cps/
INSERIES is an input SAS data set that lists the IDs of the time series to be retrieved from the Current Population Statistics 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, four time series are requested, along with any calculations.
The date range of the data starts with 2021, as specified by the STARTYEAR= option. The ENDYEAR= option specifies the last year, 2022, to include in the range of data to retrieve. The FREQ=QUARTERLY option specifies the selection of quarterly 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.7.1 shows the data that are retrieved. Output 23.7.2 shows the catalog information for the retrieved data.
options;
libname blscat "%sysget(BLS)"; /* for Catalog data set*/
DATA inseries;
length seriesid $ 32;
seriesid = 'LNS11000000Q'; output;
seriesid = 'LNS11000012Q'; output;
seriesid = 'LES1252881500'; output;
seriesid = 'LES1252882800'; output;
RUN;
title 'Retrieve Labor Force Current Population Statistics Data';
libname bls sasebls "%sysget(BLS)"
USER='XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
SETNAME=CPS
INSET=inseries
PAYPATH= "%sysget(BLS)payload"
OUTJSON=blsex07
STARTYEAR='2021'
ENDYEAR='2022'
FREQ=Quarterly
CALCULATIONS=true
CATALOG=true
FORMAT=json;
data myCPS;
set bls.blsex07 ;
run;
proc contents data=myCPS; run;
proc print data=myCPS; run;
Output 23.7.1: Weekly Earnings and Civilian Labor Force Level: Current Population Statistics
| Retrieve Labor Force Current Population Statistics Data |
| Obs | year | period | periodName | LES1252881500 | LES1252881500_3 | LES1252881500_6 | LES1252881500_12 | LES1252881500%3 | LES1252881500%6 | LES1252881500%12 | LES1252882800 | LES1252882800_3 | LES1252882800_6 | LES1252882800_12 | LES1252882800%3 | LES1252882800%6 | LES1252882800%12 | LNS11000000Q | LNS11000000Q_3 | LNS11000000Q_6 | LNS11000000Q_12 | LNS11000000Q%3 | LNS11000000Q%6 | LNS11000000Q%12 | LNS11000012Q | LNS11000012Q_3 | LNS11000012Q_6 | LNS11000012Q_12 | LNS11000012Q%3 | LNS11000012Q%6 | LNS11000012Q%12 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 2021 | Q01 | 1st Quarter | 983 | 0 | -11 | 32 | 0.0 | -1.1 | 3.4 | 340 | -2 | -7 | 10 | -0.6 | -2.0 | 3.0 | 160225 | -571 | -124 | -3588 | -0.4 | -0.1 | -2.2 | 5938 | -12 | 268 | -77 | -0.2 | 4.7 | -1.3 |
| 2 | 2021 | Q02 | 2nd Quarter | 996 | 13 | 13 | -12 | 1.3 | 1.3 | -1.2 | 337 | -3 | -5 | -22 | -0.9 | -1.5 | -6.1 | 160947 | 722 | 151 | 2855 | 0.5 | 0.1 | 1.8 | 5993 | 55 | 43 | 666 | 0.9 | 0.7 | 12.5 |
| 3 | 2021 | Q03 | 3rd Quarter | 1001 | 5 | 18 | 7 | 0.5 | 1.8 | 0.7 | 335 | -2 | -5 | -12 | -0.6 | -1.5 | -3.5 | 161521 | 574 | 1296 | 1172 | 0.4 | 0.8 | 0.7 | 5949 | -44 | 11 | 279 | -0.7 | 0.2 | 4.9 |
| 4 | 2021 | Q04 | 4th Quarter | 1010 | 9 | 14 | 27 | 0.9 | 1.4 | 2.7 | 333 | -2 | -4 | -9 | -0.6 | -1.2 | -2.6 | 162155 | 634 | 1208 | 1359 | 0.4 | 0.8 | 0.8 | 5974 | 25 | -19 | 24 | 0.4 | -0.3 | 0.4 |
| 5 | 2022 | Q01 | 1st Quarter | 1032 | 22 | 31 | 49 | 2.2 | 3.1 | 5.0 | 329 | -4 | -6 | -11 | -1.2 | -1.8 | -3.2 | 163932 | 1777 | 2411 | 3707 | 1.1 | 1.5 | 2.3 | 6215 | 241 | 266 | 277 | 4.0 | 4.5 | 4.7 |
| 6 | 2022 | Q02 | 2nd Quarter | 1048 | 16 | 38 | 52 | 1.6 | 3.8 | 5.2 | 326 | -3 | -7 | -11 | -0.9 | -2.1 | -3.3 | 164077 | 145 | 1922 | 3130 | 0.1 | 1.2 | 1.9 | 6243 | 28 | 269 | 250 | 0.5 | 4.5 | 4.2 |
| 7 | 2022 | Q03 | 3rd Quarter | 1070 | 22 | 38 | 69 | 2.1 | 3.7 | 6.9 | 327 | 1 | -2 | -8 | 0.3 | -0.6 | -2.4 | 164441 | 364 | 509 | 2920 | 0.2 | 0.3 | 1.8 | 6280 | 37 | 65 | 331 | 0.6 | 1.0 | 5.6 |
| 8 | 2022 | Q04 | 4th Quarter | 1084 | 14 | 36 | 74 | 1.3 | 3.4 | 7.3 | 327 | 0 | 1 | -6 | 0.0 | 0.3 | -1.8 | 164713 | 272 | 636 | 2558 | 0.2 | 0.4 | 1.6 | 6367 | 87 | 124 | 393 | 1.4 | 2.0 | 6.6 |
The following statements print the catalog information shown in Output 23.7.2:
libname blscat "%sysget(BLS)"; /* for Catalog data set*/
data myCAT;
set blscat.blsex07_catalog;
run;
proc print data=blscat.blsex07_catalog; run;
Output 23.7.2: Catalog for Weekly Earnings and Civilian Labor Force Level: Current Population Statistics
| Retrieve Labor Force Current Population Statistics Data |
| Obs | ordinal_series | ordinal_catalog | series_title | series_id | seasonality | survey_name | survey_abbreviation | measure_data_type | commerce_industry | occupation | occupation_work_class | cps_labor_force_status | demographic_age | demographic_ethnic_origin | demographic_race | demographic_gender | demographic_education |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 1 | 1 | (Seas)- Median usual weekly earnings (second quartile), Employed full time, Wage and salary workers | LES1252881500 | Seasonally Adjusted | Weekly and hourly earnings data from the Current Population Survey | LE | Median usual weekly earnings - in current dollars (second quartile) | All Industries | All Occupations | Wage and salary workers, excluding incorporated self employed | Employed full time | 16 years and over | All Origins | All Races | Both Sexes | All educational levels |
| 2 | 2 | 2 | (Seas)- Constant (1982-84) dollar adjusted to CPI-U- Median usual weekly earnings, Employed full time, Wage and salary workers, Women | LES1252882800 | Seasonally Adjusted | Weekly and hourly earnings data from the Current Population Survey | LE | Median usual weekly earnings - in constant (1982-84) dollars | All Industries | All Occupations | Wage and salary workers, excluding incorporated self employed | Employed full time | 16 years and over | All Origins | All Races | Women | All educational levels |
| 3 | 3 | 3 | (Seas) Civilian Labor Force Level | LNS11000000Q | Seasonally Adjusted | Labor Force Statistics from the Current Population Survey | LN | Number in thousands | All Industries | All Occupations | Civilian labor force | 16 years and over | All Origins | All Races | Both Sexes | All educational levels | |
| 4 | 4 | 4 | (Seas) Civilian Labor Force Level - 16-19 yrs. | LNS11000012Q | Seasonally Adjusted | Labor Force Statistics from the Current Population Survey | LN | Number in thousands | All Industries | All Occupations | Civilian labor force | 16 to 19 years | All Origins | All Races | Both Sexes | All educational levels |