SASEBLS Interface Engine
Example 23.12 Retrieving American Time Use Survey (ATUS) Data
This example shows how to retrieve American Time Use Survey (ATUS) data. You can view these data by using the following URL:
https://www.bls.gov/tus/database.htm
INSERIES is an input SAS data set that lists the IDs of the time series to be read from the ATUS 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 to retrieve using their IDs. In this example, four time series are requested.
The date range of the data starts with 2009, as specified by the STARTYEAR= option. The ENDYEAR= option specifies the last year, 2019, to include in the range of data to retrieve. The FREQ=ANNUAL (or FREQ=A) option specifies the selection of annual data. The ASPECTS=TRUE option is specified, and the data that are retrieved show the standard error, name_aspects, and the value, value_aspects, that are associated with each observation of each time series. The FORMAT= option specifies that the data are to be retrieved using the JSON format. Output 23.12.1 shows the data that are retrieved. Output 23.12.2 shows the catalog information for the retrieved data. Output 23.12.3 shows the aspects information for the retrieved data.
options;
libname blscat "%sysget(BLS)"; /* for Catalog data set*/
DATA inseries;
length seriesid $ 32;
seriesid = 'TUU10101AA01001181'; output;
seriesid = 'TUU10101AA01001260'; output;
seriesid = 'TUU20101AA01002999'; output;
seriesid = 'TUU20101AA01003084'; output;
RUN;
title 'Retrieve American Time Use Survey Data';
libname bls sasebls "%sysget(BLS)"
USER='XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
SETNAME=ATUS
INSET=inseries
PAYPATH= "%sysget(BLS)payload"
OUTJSON=blsex12
STARTYEAR='2009'
ENDYEAR='2019'
FREQ=Annual
ASPECTS=true
CATALOG=true
FORMAT=json;
data myTUS;
set bls.blsex12;
run;
proc contents data=myTUS; run;
proc print data=myTUS; run;
Output 23.12.1: American Time Use Survey Data
| Retrieve American Time Use Survey Data |
| Obs | year | period | periodName | TUU10101AA01001181 | TUU10101AA01001260 | TUU20101AA01002999 | TUU20101AA01003084 |
|---|---|---|---|---|---|---|---|
| 1 | 2009 | A01 | Annual | 0.29 | 0.77 | 7.90 | 6.97 |
| 2 | 2010 | A01 | Annual | 0.32 | 0.79 | 7.82 | 7.14 |
| 3 | 2011 | A01 | Annual | 0.31 | 0.79 | 8.00 | 7.21 |
| 4 | 2012 | A01 | Annual | 0.28 | 0.75 | 8.07 | 7.16 |
| 5 | 2013 | A01 | Annual | 0.33 | 0.80 | 7.97 | 7.08 |
| 6 | 2014 | A01 | Annual | 0.34 | 0.82 | 8.14 | 7.28 |
| 7 | 2015 | A01 | Annual | 0.35 | 0.83 | 7.91 | 7.21 |
| 8 | 2016 | A01 | Annual | 0.35 | 0.82 | 8.04 | 7.11 |
| 9 | 2017 | A01 | Annual | 0.36 | 0.83 | 8.05 | 7.24 |
| 10 | 2018 | A01 | Annual | 0.37 | 0.80 | 7.88 | 7.31 |
| 11 | 2019 | A01 | Annual | 0.39 | 0.79 | 7.97 | 7.17 |
The following statements print the catalog data shown in Output 23.12.2:
libname blscat "%sysget(BLS)";
data myCAT;
set blscat.blsex12_catalog;
run;
proc print data=myCAT; run;
Output 23.12.2: Catalog for American Time Use Survey Data
| Retrieve American Time Use Survey Data |
| Obs | ordinal_series | ordinal_catalog | series_title | series_id | seasonality | survey_name | survey_abbreviation | measure_data_type | cps_labor_force_status | demographic_age | demographic_race | demographic_gender | demographic_children | demographic_education | cps_family_children | cps_activity | day_of_week | earnings |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 1 | 1 | Avg hrs per day - Food preparation and cleanup, Men | TUU10101AA01001181 | Not Seasonally Adjusted | American Time Use | TU | Average hours per day | All persons | 15 years and over | All races | Men | All persons | All education levels | All persons | Food preparation and cleanup | All days | All persons |
| 2 | 2 | 2 | Avg hrs per day - Food preparation and cleanup, Women | TUU10101AA01001260 | Not Seasonally Adjusted | American Time Use | TU | Average hours per day | All persons | 15 years and over | All races | Women | All persons | All education levels | All persons | Food preparation and cleanup | All days | All persons |
| 3 | 3 | 3 | Avg hrs per day for participants - Working, Employed, Men | TUU20101AA01002999 | Not Seasonally Adjusted | American Time Use | TU | Average hours per day for participants in an activity | Employed | 15 years and over | All races | Men | All persons | All education levels | All persons | Working | All days | All persons |
| 4 | 4 | 4 | Avg hrs per day for participants - Working, Employed, Women | TUU20101AA01003084 | Not Seasonally Adjusted | American Time Use | TU | Average hours per day for participants in an activity | Employed | 15 years and over | All races | Women | All persons | All education levels | All persons | Working | All days | All persons |
The following statements print the aspects data as shown in Output 23.12.3. Each time series has its own corresponding name aspects and value aspects time series. The first series, TUU10101AA01001181, has the corresponding name aspects time series TUU10101AA01001181_name_aspects, and it also has the corresponding value aspects time series TUU10101AA01001181_value_aspects. This naming convention, where the time series name also appears as a prefix in the name aspects and value aspects series names, is used for each of the retrieved series.
libname blscat "%sysget(BLS)";
data myASPECTS;
set blscat.blsex12_data_aspects;
run;
proc print data=myASPECTS; run;
Output 23.12.3: Aspects Output for American Time Use Survey Data
| Retrieve American Time Use Survey Data |
| Obs | year | period | periodName | TUU10101AA01001181 | TUU10101AA01001181_name_asp | TUU10101AA01001181_val_asp | TUU10101AA01001260 | TUU10101AA01001260_name_asp | TUU10101AA01001260_val_asp | TUU20101AA01002999 | TUU20101AA01002999_name_asp | TUU20101AA01002999_val_asp | TUU20101AA01003084 | TUU20101AA01003084_name_asp | TUU20101AA01003084_val_asp |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 2009 | A01 | Annual | 0.29 | Standard Error | 0.010 | 0.77 | Standard Error | 0.013 | 7.90 | Standard Error | 0.076 | 6.97 | Standard Error | 0.059 |
| 2 | 2010 | A01 | Annual | 0.32 | Standard Error | 0.009 | 0.79 | Standard Error | 0.015 | 7.82 | Standard Error | 0.072 | 7.14 | Standard Error | 0.079 |
| 3 | 2011 | A01 | Annual | 0.31 | Standard Error | 0.010 | 0.79 | Standard Error | 0.017 | 8.00 | Standard Error | 0.074 | 7.21 | Standard Error | 0.067 |
| 4 | 2012 | A01 | Annual | 0.28 | Standard Error | 0.009 | 0.75 | Standard Error | 0.014 | 8.07 | Standard Error | 0.079 | 7.16 | Standard Error | 0.077 |
| 5 | 2013 | A01 | Annual | 0.33 | Standard Error | 0.011 | 0.80 | Standard Error | 0.014 | 7.97 | Standard Error | 0.078 | 7.08 | Standard Error | 0.072 |
| 6 | 2014 | A01 | Annual | 0.34 | Standard Error | 0.011 | 0.82 | Standard Error | 0.016 | 8.14 | Standard Error | 0.080 | 7.28 | Standard Error | 0.069 |
| 7 | 2015 | A01 | Annual | 0.35 | Standard Error | 0.013 | 0.83 | Standard Error | 0.016 | 7.91 | Standard Error | 0.078 | 7.21 | Standard Error | 0.083 |
| 8 | 2016 | A01 | Annual | 0.35 | Standard Error | 0.012 | 0.82 | Standard Error | 0.017 | 8.04 | Standard Error | 0.074 | 7.11 | Standard Error | 0.080 |
| 9 | 2017 | A01 | Annual | 0.36 | Standard Error | 0.012 | 0.83 | Standard Error | 0.022 | 8.05 | Standard Error | 0.072 | 7.24 | Standard Error | 0.088 |
| 10 | 2018 | A01 | Annual | 0.37 | Standard Error | 0.013 | 0.80 | Standard Error | 0.017 | 7.88 | Standard Error | 0.083 | 7.31 | Standard Error | 0.081 |
| 11 | 2019 | A01 | Annual | 0.39 | Standard Error | 0.012 | 0.79 | Standard Error | 0.016 | 7.97 | Standard Error | 0.083 | 7.17 | Standard Error | 0.091 |