SASEBLS Interface Engine
Example 23.6 Retrieving State and Metro Area Current Employment (SM) Data
This example shows how to retrieve data from the State and Metro Area Current Employment Survey (SM). You can view these data by using the following URL:
https://www.bls.gov/sae/data/
INSERIES is an input SAS data set that lists the IDs of the time series to be retrieved from the State and Metro Area Current Employment Statistics (SAE) 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, SMU78000009092000001 and SMS39496600000000001, 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 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=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.6.1 shows the first seven observations of data that are retrieved. Output 23.6.2 shows the catalog information for the retrieved data.
options;
DATA inseries;
length seriesid $ 32;
seriesid = 'SMU78000009092000001 '; output;
seriesid = 'SMS39496600000000001'; output;
RUN;
title 'Retrieve State and Metro Area Current Employment Statistics Data';
libname bls sasebls "%sysget(BLS)"
USER='XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
SETNAME=SAE
INSET=inseries
PAYPATH= "%sysget(BLS)payload"
OUTJSON=blsex06
STARTYEAR='2021'
ENDYEAR='2022'
FREQ=Month
CALCULATIONS=true
CATALOG=true
FORMAT=json;
data mySAE;
set bls.blsex06 ;
run;
proc contents data=mySAE; run;
proc print data=mySAE(obs=7); run;
Output 23.6.1: State and Area Employment, Hours, and Earnings: Total Nonfarm and State Government
| Retrieve State and Metro Area Current Employment Statistics Data |
| Obs | year | period | periodName | SMS39496600000000001 | SMS39496600000000001_1 | SMS39496600000000001_3 | SMS39496600000000001_6 | SMS39496600000000001_12 | SMS39496600000000001%1 | SMS39496600000000001%3 | SMS39496600000000001%6 | SMS39496600000000001%12 | SMU78000009092000001 | SMU78000009092000001_1 | SMU78000009092000001_3 | SMU78000009092000001_6 | SMU78000009092000001_12 | SMU78000009092000001%1 | SMU78000009092000001%3 | SMU78000009092000001%6 | SMU78000009092000001%12 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 2021 | M01 | January | 199.7 | 2.1 | 0.1 | 3.2 | -16.0 | 1.1 | 0.1 | 1.6 | -7.4 | 9.4 | -0.1 | -0.8 | -1.0 | -0.1 | -1.1 | -7.8 | -9.6 | -1.1 |
| 2 | 2021 | M02 | February | 199.2 | -0.5 | 0.3 | 1.3 | -16.0 | -0.3 | 0.2 | 0.7 | -7.4 | 9.6 | 0.2 | -0.6 | -0.4 | -0.1 | 2.1 | -5.9 | -4.0 | -1.0 |
| 3 | 2021 | M03 | March | 200.9 | 1.7 | 3.3 | 1.6 | -11.4 | 0.9 | 1.7 | 0.8 | -5.4 | 9.6 | 0.0 | 0.1 | -0.4 | -0.5 | 0.0 | 1.1 | -4.0 | -5.0 |
| 4 | 2021 | M04 | April | 201.7 | 0.8 | 2.0 | 2.1 | 28.1 | 0.4 | 1.0 | 1.1 | 16.2 | 9.7 | 0.1 | 0.3 | -0.5 | -0.6 | 1.0 | 3.2 | -4.9 | -5.8 |
| 5 | 2021 | M05 | May | 201.4 | -0.3 | 2.2 | 2.5 | 19.5 | -0.1 | 1.1 | 1.3 | 10.7 | 9.6 | -0.1 | 0.0 | -0.6 | -0.6 | -1.0 | 0.0 | -5.9 | -5.9 |
| 6 | 2021 | M06 | June | 202.1 | 0.7 | 1.2 | 4.5 | 9.5 | 0.3 | 0.6 | 2.3 | 4.9 | 9.7 | 0.1 | 0.1 | 0.2 | 0.0 | 1.0 | 1.0 | 2.1 | 0.0 |
| 7 | 2021 | M07 | July | 203.3 | 1.2 | 1.6 | 3.6 | 6.8 | 0.6 | 0.8 | 1.8 | 3.5 | 10.1 | 0.4 | 0.4 | 0.7 | -0.3 | 4.1 | 4.1 | 7.4 | -2.9 |
The following statements print the catalog information shown in Output 23.6.2:
libname blscat "%sysget(BLS)"; /* for Catalog data set*/
data myCAT;
set blscat.blsex06_catalog;
run;
proc print data=blscat.blsex06_catalog; run;
Output 23.6.2: Catalog for State and Area Employment, Hours, and Earnings: Total Nonfarm and State Government
| Retrieve State and Metro Area 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 | area |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 1 | 1 | Employed and Office of Employment and Unemployment Statistics : Total Nonfarm - Total Nonfarm | SMS39496600000000001 | Seasonally Adjusted | State and Area Employment, Hours, and Earnings | SM | All Employees, In Thousands | Total Nonfarm | Total Nonfarm | Youngstown-Warren-Boardman, OH-PA |
| 2 | 2 | 2 | Employed and Office of Employment and Unemployment Statistics : Government - State Government | SMU78000009092000001 | Not Seasonally Adjusted | State and Area Employment, Hours, and Earnings | SM | All Employees, In Thousands | State Government | Government | Virgin Islands |