Gender and sexual diversity statistical metadata standards

Opened: February 2, 2021
Closed: March 12, 2021
Results posted: August 16, 2023

Consultation objectives

In recent years, there has been an increase in public awareness and sensitivity in Canada towards the 2SLGBTQI+ population. However, existing statistical data and information on this population have remained limited.

To address these information gaps, Statistics Canada has developed statistical metadata standards to better respond to the data needs on gender and sexual diversity in Canada. Throughout this process, Statistics Canada has engaged with stakeholders and partners, including civil society organizations, as well as researchers in the field of gender and sexual diversity and gender studies.

Among engagement activities, Statistics Canada launched a public consultation in 2021 on the proposed updated gender and new sexual orientation and LGBTQ2+Footnote 1 standards, inviting members of the Canadian public and international partners to review them and provide feedback to ensure their relevance.

Consultation methodology

This consultative engagement initiative is now closed.

The public consultation on gender and sexual diversity statistical metadata standards was conducted electronically. It was publicized through public announcements that described the proposed updates to the standard for gender of person, which was first released in April, 2018. The announcements also proposed new standards for sexual orientation of person and LGBTQ2+ status of person and listed the types of inputs sought.

Announcements were disseminated through the Statistics Canada's website and social media. Moreover, stakeholders and partners, civil society organizations and researchers were invited by email to participate and to share the consultation invitation with others within their network.  

In addition to the public consultation, virtual meetings were organized in both official languages with partners and researchers to gather their feedback.

How participants got involved

Overall, Statistics Canada received 205 responses by email in both official languages from a range of individuals and organizations, including academics and research groups, civil society organizations, government departments and agencies at the federal, provincial and territorial level in Canada and overseas, academics and researchers, and the general public.

The consultation also included several follow up discussions in both official languages with academics and subject-matter experts.

Results

Statistics Canada has completed the review process for the updated gender standard and the new sexual orientation standard. The updated gender standard was released on October 1, 2021. All comments received during this consultation and other engagements activities were taken into account, and many are reflected in the updated standard.

The new sexual orientation standard was released on August 16, 2023. The public consultation was one of four phases that informed the development of the sexual orientation standard. In addition to the public consultation, Statistics Canada undertook a targeted expert consultation, focus groups, and a testing phase which consisted of one-on-one interviews.

Statistics Canada thanks members of the Canadian public and international partners for their involvement in this consultative engagement initiative.

The report is available in HTML and PDF formats: 2021 Public onsultation on Gender and Sexual Diversity Statistical Metadata Standards - What We Heard Report

Plans at a glance

As the national statistical office, Statistics Canada provides Canadians with key information on Canada's economy, society and environment. The agency's data and insights help individuals, businesses and governments make informed decisions. For example, Statistics Canada data help Canadians understand how changes in the inflation rate can affect their pocketbooks. The data also enable Canadian companies to make key business decisions. They provide government officials with vital evidence to promote economic growth, plan roads and cities, adjust pensions, and develop employment and social programs that benefit Canadians.

Over the past year, the COVID-19 pandemic has accelerated Statistics Canada's mission to find innovative ways to bring new data and insights to Canadians, whenever and wherever they are needed. Never have data-driven insights been more important in enabling Canadians to see challenges and opportunities sooner, and act on them faster. Statistics Canada has leveraged its multi-year modernization effort to respond to Canadians' evolving data needs during the pandemic in agile, adaptive and innovative ways.

The agency also recognizes that the need for trusted, high-quality data—and responsible stewardship of those data—has never been greater, as people and institutions navigate a digital, data-driven world where more and more data are coming from a wider variety of sources. To that end, Statistics Canada's major focus over the coming year will be the 2021 Census of Population and Census of Agriculture. The census, conducted every five years, is the most authoritative snapshot of the people of Canada and the most important source of disaggregated data. The 2021 Census will take place during the pandemic and will therefore require adaptations to ensure it is conducted safely and provides comprehensive information on the impacts of COVID-19.

Statistics Canada's ongoing modernization efforts will be embedded within these priorities. As a result, Statistics Canada will also focus on the following actions in 2021–22.

Strengthening the statistical system

Despite the pandemic and the rapid pace of change, one thing has remained constant at Statistics Canada—to continue being an independent and trusted source of official statistics, ensuring confidentiality and trust through every stage of data dissemination.

Building an agile workforce and culture

As part of a whole-of-government initiative, and working with partners such as Shared Services Canada, Statistics Canada continues to adopt new technologies that enable its employees to work remotely, securely and safely during the pandemic. The agency is also equipping employees with the skills, technology and continuous-improvement mindset to adapt to rapidly evolving data needs. These initiatives include

  • new secure digital platforms that enable staff to collaborate virtually
  • strengthened and integrated protocols to meet the highest security requirements so that Canadians' data are strictly protected
  • training and skills upgrading for employees to encourage lifelong learning and ensure they are equipped to use next-generation data analytics tools.

Delivering user-friendly services

Statistics Canada is actively developing technology-based solutions to increase Canadians' access to timely, high-quality data in user-friendly formats, on demand. In response to the pandemic, the agency is accelerating its shift from collecting and storing fixed, static data stocks to sharing dynamic data flows.

The goal is to use data as they should be used in the digital age: as rapidly moving knowledge flows that can be turned into timely and meaningful insights on demand. These can be used by more Canadians to guide their decision-making, especially during critical situations such as the pandemic response.
The agency will continue to find fresh ways to present and share data so that they are easier for anyone to find and use, including

  • modernizing the look and feel of web and social media content
  • developing on-demand data subscription services
  • launching online data hubs organized by topic
  • adding more data visualization products that provide a user-friendly approach to understanding the data
  • striving to make communications clear and accessible to all Canadians.

Using leading-edge methods

Statistics Canada's activities have always been driven by sound data strategies. The agency will continue to explore new methods of collecting data that move beyond the survey-first approach. These include using innovative data collection approaches, such as web panels, and integrating more administrative data (existing non-survey-based information from a variety of sources) with data science approaches, while strictly preserving the confidentiality and security of those data.

Given the uncertainty created by COVID-19, the agency will continue to provide more targeted, timely and detailed data on emerging issues that affect Canada's economy and society. These will be released both during the pandemic and over the longer term as the country recovers.

In particular, Statistics Canada will continue to place an urgent priority on disaggregating more datasets, where feasible. This will better identify the economic and social inequalities experienced by vulnerable populations, such as women, Indigenous people, Canadians living with disabilities, groups designated as visible minorities and the LGBTQ+ community. To better understand the unequal impacts of the economic downturn caused by COVID-19, the agency will continue to explore how to address data gaps in several statistical programs, including its flagship Labour Force Survey.

Collaborating and engaging with more Canadians

Collaborating with public and private sector partners, Statistics Canada will continue to identify new ways to collect and share data, while maintaining the high standard of trust that Canadians have come to expect. To ensure that more data are integrated from a variety of sources and that more end users have the information they need to make evidence-based decisions, the agency has already identified more opportunities to collaborate with new and existing partners. These partnerships will continue to grow as the country moves beyond pandemic response towards recovery.

Building statistical capacity and fostering data literacy

Statistics Canada will continue to be a national data literacy leader through its data strategy signature initiatives and the newly created Office of the Chief Data Officer. The agency will maintain a proactive and coordinated approach to drive the use of data as a strategic asset throughout the Government of Canada and will provide support to other federal organizations.

Through partnerships with Indigenous people, organizations and communities, Statistics Canada will work alongside them to enhance their capacity to build and maintain their own statistical programs, grounded in their needs and based on recognition of rights, respect and collaboration.

The agency, whose expertise is recognized globally, will continue to play a leadership role on the world stage. In partnership with the United Nations, the Organisation for Economic Development and Co-operation, and other national statistical offices, Statistics Canada will continue to provide technical assistance to strengthen the capacity of developing countries so that they can build and maintain their own statistical programs.

Collaborating effectively in the international community enables Statistics Canada to lead by example and build upon its reputation; this kind of engagement promotes the development and use of strong statistics. Thoughtful and effective international partnerships also expand Canada's influence in trade, global governance and the promotion of equality.

For more information on Statistics Canada's plans, priorities and planned results, see the "Core responsibilities: planned results and resources, and key risks" section of this report.

Chief Statistician's message

Cheif Statistician Anil Arora

I am pleased to present Statistics Canada's 2021-22 Departmental Plan.

This report outlines how the agency is fulfilling its mandate over the coming year to provide Canadians with timely, high-quality data for decisions that impact all of us.

The COVID-19 pandemic has accelerated Statistics Canada's multi-year modernization efforts, and fundamentally transformed the way we operate. And thanks to this modernization and to our dedicated staff, we were well prepared. Almost overnight, we were able to quickly pivot operations to focus on mission-critical programs, and move some 7,500 employees to telework. Faced with an unprecedented need for data, they stepped up to the plate, enabling the agency to deliver data-driven insights to Canadians at a time when they were needed most.

At no time has the role of data – and Statistics Canada's role as a trusted data steward – been more important in helping Canadians not only survive this crisis, but also thrive once we move past it.

Our effort to modernize our operations is based on five pillars:

  • Fostering a modern and flexible workplace based on an agile workforce and culture.
  • Delivering user-centric products and services to focus resources on what clients want and need today, and to make Statistics Canada data easier for anyone to find and use.
  • Using leading-edge methods. We do this by identifying new methods of collecting data that move beyond the survey-first approach, finding new ways to integrate data from a variety of sources, and using high-throughput tools to analyze and visualize data.
  • Collaborating and engaging with partners, sharing expertise, and increasing access to data.
  • Building statistical capacity with partners and fostering data literacy among Canadians so that more end-users – whether they are businesses, governments or citizens – can make evidence-based decisions from data.

To that end, Statistics Canada will deliver results over the coming year based on the following priorities:

  • Strengthening the Statistical System. The Canadian Statistics Advisory Council (CSAC) released, in October 2020, the first annual report which provides a detailed assessment of Canada’s statistical system and advice on how it could be strengthened. Statistics Canada will work closely with partners within and outside the federal government to make tangible progress in the areas recommended in the report.
  • Launch the 2021 Census of the Population and Census of Agriculture. Every five years, the censuses provide a detailed portrait of Canadians and their communities. In 2021, census data collection will take place against the backdrop of a pandemic, which will require Statistics Canada employees to adapt to public-health measures, such as physical distancing, during the collection of census data. The data collected for this census will also capture the sheer scale of the social and economic impacts that Canadians continue to face as a result of COVID-19.
  • Enhance coverage of emerging social and economic concerns. Statistics Canada will continue to produce more data on important issues, such as housing affordability, health outcomes, household debt and Canadians' quality of life. Given the economic uncertainty created by COVID-19, we will also identify timely and accurate indicators to track the sharp changes in employment levels and business activity during an economic shock. Another urgent priority is to disaggregate datasets to better identify the economic and social impact of COVID-19 on vulnerable populations, such as women, Indigenous people, people living with disabilities, the LGBTQ+ community, and groups designated as visible minorities.
  • Seek out data from alternative sources. Canadians often wonder why they are asked to provide the same data multiple times to government institutions. That's why we will engage with Canadians and collaborate with both public- and private-sector partners on ways to collect, store and share administrative data – information not based on surveys that are already held by other organizations. The objective is to make Statistics Canada more responsive to the data needs of Canadians, without adding extra demands on them to provide the same information to us multiple times. This commitment is part of the Government of Canada's vision of offering services focused on the needs of end users. Better data integration from various sources means the federal government has a better sense of the needs of Canadians. Better data integration holds great potential for making Canadians' interactions with the Government of Canada easier, providing them with a more seamless experience when they seek a service or benefit. It can make government more efficient, better at coordinating public services and better equipped to make evidence-based decisions that can improve the lives of all Canadians, particularly those who may not have benefitted equally in the past. And as we seek to integrate more data to better serve Canadians, we will continue to strictly protect their privacy.
  • Build statistical capacity and foster data literacy. Through newly established partnerships with Indigenous communities, we will share our globally recognized expertise in using data for public accountability, social impact and innovation. We will also continue to collaborate with other federal departments as well as our provincial and territorial counterparts to use data as a strategic asset to better serve Canadians.
  • Modernize our operations. To better meet Canada's evolving data needs, especially during a public-health crisis, we are actively developing new technology-based solutions to provide Canadians with increased access to timely, high-quality data. We are investing in secure digital infrastructure to protect the data assets that Canadians have entrusted to us. We are also launching new on-demand digital tools and services – part of our commitment to improve our services to Canadians by identifying fresh ways to model and present data to them.

Over the past century, Statistics Canada has evolved from being the nation's collector and keeper of fixed stocks of data, to being a dynamic service provider that shares ever-moving flows of data, wherever and whenever they are needed. These data can be used by many more Canadians, who are looking for accurate, authoritative information tailored to their unique needs to make important decisions.

We will continue to strictly protect the information Canadians have entrusted to Statistics Canada and be transparent about the methods that we use to ensure that their information is both secure and kept strictly confidential. I invite Canadians to visit Statistics Canada's Trust Centre to see how we are introducing world-leading privacy-protection methods and how our dedicated employees work to bring Canadians the data and insights that they have counted on for more than 100 years.

Anil Arora
Chief Statistician of Canada

From the Minister

The Honourable François-Philippe Champagne, P.C., M.P.

The Honourable François-Philippe Champagne
Minister of Innovation, Science and Industry

Statistics Canada and Innovation, Science and Economic Development Canada (ISED) are working to position Canada as an innovation leader on the global stage by fostering a diverse, growing, competitive and sustainable economy that benefits all Canadians.

While our government's priority continues to be fighting COVID-19 and protecting Canadians' health and safety, we are committed to fostering conditions for investment, enhancing Canadian innovation, and driving growth in key sectors. Together, we will strengthen the Canadian economy and restore consumer confidence through strategic actions, including investing in training for workers, and supporting Canadian businesses as they adapt and grow in a knowledge-based economy.

Statistics Canada, as the country's national statistical office, will continue to support key government priorities by advancing efforts in the following areas; gender equality, diversity and inclusion, public health data management, energy, environment and sustainable development. The agency will work to build statistical capacity in Indigenous organizations, and meet the increasing need for data to help fuel our economy and labour market. And, thanks to the participation of thousands of Canadians, Statistics Canada will deliver the 2021 Census that provides a detailed and comprehensive statistical portrait of Canada that is vital to our country.

Statistics Canada's ambitious modernization agenda has positioned the agency to be responsive to the COVID-19 crisis. As we navigate a path to recovery, Statistics Canada will continue to deliver meaningful insights. More than ever, Canadians need timely, granular and integrated data to shed light on the impacts of the pandemic on Canadian society and our economy.

Finally, in tackling some of today's most pressing challenges, such as climate change, we will continue to invest in science and research. We will also ensure that federal research is fully available to the public; that researchers can freely share their work; and that evidence-based approaches are utilized when making decisions. In doing so, we will facilitate the kind of new discoveries made by Canada's leading researchers and academics.

Together with Canadians of all backgrounds, regions and generations, we are building a strong culture of innovation to position Canada as a leader in the global economy. For more information, it is our pleasure to present the 2021-22 Departmental Plan for Statistics Canada.

Survey of Labour and Income Dynamics (SLID)

About SLID

About SLID

Survey of Labour and Income Dynamics (SLID) data RETrievel system (SLIDRET) acts as an interface between the database and the user. SLIDRET allows users to create a dataset according to their own specifications. The custom query (.qry) files is submitted to the Real Time Remote Access (RTRA) along with the SAS program. The software is needed to access SLID and is available free of charge via the client service unit.

Note on SLIDRET:

The RTRA system only accepts cross-sectional extractions from SLIDRet. RTRA users should ensure to select CrossSection under "Type of analysis" in the SLIDRet application.

SLIDRet automatically provides the appropriate weight variable option associated with the unit of analysis in "5. Run Query". Therefore, a RTRA user does not need to specify a weight variable (eg: ILBWT26 or WTCSLD26) in "2. Variable Selection" in SLIDRet. An error will occur if a RTRA user submits a query file with more than one weight variable identified.

Submissions

Submissions

For SLID submissions, we recommend that you convert your SAS code and Query files into .zip files. RTRA allows .zip files to be submitted. This ensures that RTRA will pair the .sas and .qry files correctly. When you submit two files (.sas and .qry) instead of a .zip file, there's a chance that RTRA will not be able to pair the .sas and .qry files.

  1. Create a ZIP file with the files SLIDQRY_name.sas and SLIDQRY_some.qry in it. The ZIP file itself can be named anything.
  2. Place the ZIP files in the Inbox.
  3. RTRA will automatically extract the files in the ZIP, put them in the Inbox and prefix the files with same date and time stamp so that they can be matched. Processing then happens as usual.
Share this page
Date modified:

System limitations

SAS compatibility

SAS compatibility

The Real Time Remote Access (RTRA) system uses SAS version 9.4 and data requests must be submitted in the form of SAS programs in plain American Standard Code for Information Interchange (ASCII) format. Statistics Canada does not provide programming assistance, or make modifications to the programs that are submitted. If a program does not run properly, a log will be returned with an explanation of why it failed.

Constraints

Constraints

  1. System limits
    • There are no limits to the number of programs that you can submit while you hold an active RTRA subscription. However, there is a maximum of 10 successful submissions per day
    • For each successful program submission, no more than 10 Real Time Remote Access (RTRA) procedure macro calls are permitted, resulting in a maximum of 100 tabulations that can be created per day
    • When running your SAS programs, please be advised that the maximum temporary space in SAS processing is 100 GB
    • A maximum of four or five variables can be specified in the class variable list, depending on the RTRA procedure macro being called
    • Class variables cannot contain any missing values
    • Each class variable may not have more than 500 distinct values
    • All observation counts in the SAS log returned to the user are replaced with xxxxxx.
  2. SAS restrictions

Certain SAS keywords, or statements, are not allowed through RTRA. The following list is subject to review and may be modified.

  • Certain occurrences of % and &
  • Comments of the form %*...;
  • Writing permanent datasets to RTRA system disk space
  • _ERROR_
  • _N_
  • ABORT
  • CATNAME
  • DCREATE
  • DM
  • DOPEN
  • ENDRSUBMIT
  • ENDSAS
  • ERROR
  • EXECUTE
  • FDELETE
  • FILE
  • FILENAME
  • FIRST
  • FIRSTOBS
  • FOPEN
  • FTP
  • INFILE
  • LAST
  • LIBNAME
  • MAPS
  • MAPSGFK
  • MAPSSAS
  • MODULE
  • MODULEC
  • MODULEI
  • MODULEIC
  • MODULEIN
  • MODULEN
  • MOPEN
  • OBS
  • ODS
  • OPTION
  • OPTIONS
  • PATHNAME
  • PEEK
  • PEEKC
  • PEEKCLONG
  • PEEKLONG
  • POKE
  • POKELONG
  • PRINTTO
  • PTRLONGADD
  • PUT
  • PUTLOG
  • RSUBMIT
  • SASFILE
  • SASHELP
  • SASUSER
  • SIGNOFF
  • SIGNON
  • SYMGET
  • SYMPUT
  • SYMPUTX
  • SYSTASK
  • SYSTEM
Shell program: Test your code

Shell program: Test your code

To help you test your SAS code, a shell program and a SAS macro catalog are available for download.

Please open the shell program and follow the descriptions for the different sections of the program:

Section 1

  • This section shows you how to simulate the standard libname that will be created automatically by the RTRA system
  • Make sure you change the file path to point to where you have saved your test data
  • Do not use a different libname - it must be RTRAData.

Section 2

  • This section can be discarded for testing if you have created your own set of test data
  • Survey dummy datasets are available for use in this section.

Section 3

  • This section shows you how to point to the RTRA procedure macro to create your table.
  • Change the name of the downloaded SAS macro catalog to "sasmacr"
  • Make sure you change the file path to point to where you have saved the SAS catalog provided (sasmacr.sas7bcat).

Section 4

  • This section shows you how to include your program and to run it
  • Make sure you change the file path to point to where you have saved your program.
Share this page
Date modified:

Electronic File Transfer Service

The following are the steps to send and receive files through the Electronic File Transfer (EFT) service. Follow the link to access the Electronic File Transfer Service welcome page.

Step 1

Step 1

A user account is required to access the EFT website. Enter your username and password into the appropriate fields.

After your first login, the password will expire and you will be required to enter a new one. Do not reveal your username and password to anyone – you will be held responsible for all activities related to your account.

Step 2

Step 2

Select a safe from the list of "Safe names". Select either to send "Files to Statcan" or receive "Files from Statcan".

Step 3

Step 3

If you selected to send the file "To Statcan", the "Upload" option will display. By clicking "Upload file" you will be prompted to browse your computer to select the SAS program you want Statcan to run for you.

Note: Your SAS file name must not exceed 70 characters in length.

Step 4

Step 4

Once you have selected your SAS file, it will automatically be sent to the RTRA system. If your SAS file has disappeared from the folder, it has successfully been uploaded to Statcan.

Step 5

Step 5

You can continue to upload other SAS files by using the "Upload " button or you may end this session and click the "Sign out" button in the top right hand corner of the page, under the drop-down menu.

Step 6

Step 6

E–mail notification

You will receive an email from Statistics Canada with the subject line "EFT – TEF Notification" that will include instructions on how to download your output files.

Step 7

Step 7

To download your output files, you must first login to the EFT system. If you have not already done so, please repeat Step 1 before continuing to Step 8.

Step 8

Step 8

Select your files by clicking the "From Statcan" hyperlink to view your output files. The number in front of your file name is a unique identifier for StatCan's use.

Note: You have 7 days to download your files from when you receive the email notification before they are deleted.

Share this page
Date modified:

SAS Programming Tips

Alternative to the disallowed word PUT

Alternative to the disallowed word PUT

The word PUT is not allowed in Real Time Remote Access (RTRA) because the PUT statement allows a user to write values from the microdata to the SAS  log. However, users may want to use the PUT function to create character values by applying a format (typically used to convert numeric values to character). Since the word PUT is disallowed, users can instead use the PUTC or PUTN functions which are similar to the PUT function. PUTC creates a character value by applying a character format. PUTN creates a character value by applying a numeric format.

Note: Unlike the PUT function, for the PUTC and PUTN functions the format to apply (the second argument) must be in quotation marks. For example:

AgeChar = PUTN(Age, "3.");

Converting character values to numeric

Converting character values to numeric

In some cases, a user may want to convert character microdata values to numeric. For example, the LFS microdata variable SP_WEARN is a character variable. Because of this, SP_WEARN cannot be used as an RTRA statistical analysis variable (in RTRAMean for example). It must be converted to numeric first. This conversion can be done using the INPUT function.

In the data step example below, a new numeric variable SP_WEARN_NUM is created by applying the INPUT function to SP_WEARN. It is assumed that the values in SP_WEARN include two implicit decimal places.

data work.LFS;

   set RTRAData.LFS200005;

   length SP_WEARN_NUM 8;

   SP_WEARN_NUM = INPUT(SP_WEARN,7.2);

run;

The new variable SP_WEARN_NUM can then be used as an analysis variable in the RTRA procedures.

Applying the KEEP option to the RTRAData data set

Applying the KEEP option to the RTRAData data set

Applying the KEEP option to the RTRAData data set can make the data step more efficient.  SAS will only retrieve the variables listed in the KEEP option. It is useful when only a small number of variables are needed. Note that if KEEP is specified, the variable named ID must be included in the list of variables.

For example:

data work.CSDDis;

   set RTRAData.csd2012_disab(keep=DDIS_FL REF_AGE SEX DCLASS DLFS ID);

run;

Note: While KEEP can make the data step more efficient when only a small number of variables are needed, KEEP is not a requirement. If there is a large number of variables to keep, it is easier to omit the KEEP option. SAS will automatically keep all variables (including the variable ID).

Defining new variables with a LENGTH statement

Defining new variables with a LENGTH statement

The example below shows how the values of a new character variable can be inadvertently truncated when the variable is not defined with a LENGTH statement.

data work.CSDDis;

    set RTRAData.csd2012_disab;

    if (REF_AGE < 10) then AgeGroup = "Under10";

    else if (10 <= REF_AGE <= 30) then AgeGroup = "Between10and30";

    else if (31 <= REF_AGE <= 90) then AgeGroup = "Between31and90";

    else if (REF_AGE > 90) then AgeGroup = "OlderThan90";

   else AgeGroup = "AgeUnknown";

run;

Since the new variable AgeGroup is not defined with a LENGTH statement, SAS uses the first occurrence of AgeGroup in the data step to determine the character length to assign the variable. The first occurrence is where AgeGroup is assigned the value "Under10". Therefore, SAS assigns a length of 7 to the variable AgeGroup. The problem with this is that the length of 7 is not sufficient to accommodate character values assigned to AgeGroup later in the data step, such as "Between10and30".

Here are the values of AgeGroup in the output data step for the different age groups. Notice the truncation that has occurred:

Defining new variables with a length statement
REF_AGE AgeGroup [char(7)]
< 10 Under10
10 - 30 Between
31 - 90 Between
> 90 OlderTh
Any other value AgeUnkn

If AgeGroup is a class variable, the values in the tabulated results will be truncated as shown above. Even worse, all REF_AGE values from 10 - 90 will end up in the same category – Between.

To avoid this problem, use a LENGTH statement to assign a sufficient length to AgeGroup before assigning it a value:

data work.CSDDis;

   set RTRAData.csd2012_disab;

   length AgeGroup $ 15;

   if (REF_AGE < 10) then AgeGroup = "Under10";

   else if (10 <= REF_AGE <= 30) then AgeGroup = "Between10and30";

   else if (31 <= REF_AGE <= 90) then AgeGroup = "Between31and90";

   else if (REF_AGE > 90) then AgeGroup = "OlderThan90";

   else AgeGroup = "AgeUnknown";

run;

Defining new variables with a length statement
REF_AGE AgeGroup [char(15)]
< 10 Under10
10 - 30 Between10and30
31 - 90 Between31and90
> 90 OlderThan90
Any other value AgeUnknown
Missing ELSE statement when defining a derived variable

Missing ELSE statement when defining a derived variable

When defining a derived variable in a data step, IF/ELSE statements are usually used.

For example:

data work.CSDDis;

   set RTRAData.csd2012_disab;

   length AgeGroup $ 15;

   if (0 <= REF_AGE < 10) then AgeGroup = "Under10";

   else if (10 <= REF_AGE <= 30)  then AgeGroup = "Between10and30";

   else if (31 <= REF_AGE <= 90)  then AgeGroup = "Between31and90";

   else if (91 <= REF_AGE <=120) then AgeGroup = "Between91and120";

run;

The potential problem with this code is that it ignores any special values of REF_AGE that may exist in the data. For example, the data set csd2012_disab may contain missing REF_AGE values (.) or a value such as 999 may represent "Not Stated". For observations where REF_AGE is not 0-120, AgeGroup will be set to blank. If AgeGroup is used as a class variable in RTRA, RTRA will generate an error message since a class variable cannot have any missing values.

To prevent this problem, an additional ELSE statement should be used as a "catch all". This ensures that AgeGroup will be non-blank in all observations in the output data set.

data work.CSDDis;

   set RTRAData.csd2012_disab;

   length AgeGroup $ 15;

   if (0 <= REF_AGE < 10) then AgeGroup = "Under10";

   else if (10 <= REF_AGE <= 30)  then AgeGroup = "Between10and30";

   else if (31 <= REF_AGE <= 90)  then AgeGroup = "Between31and90";

   else if (91 <= REF_AGE <=120) then AgeGroup = "Between91and120";

   else AgeGroup = "Other";

run;

In the example shown above, for all observations where REF_AGE is not 0-120, AgeGroup will be assigned a value of "Other".

Share this page
Date modified:

Controlled rounding

Rounding is performed independently on each cell (including subtotals or grand total). See Step 3 below. Here is a simple example of how rounding is performed:

Suppose we have a survey of 10 people representing a population of 1,205 and let 100 be the rounding base used by the RTRA.

Microdata

Microdata

Table 1
Controlled rounding using sex and marital status
Unit Sex Marital status Weight
1 Male Married 120.5
2 Male Widowed 120.5
3 Male Married 120.5
4 Male Divorced 120.5
5 Male Married 120.5
6 Female Married 120.5
7 Female Married 120.5
8 Female Widowed 120.5
9 Female Widowed 120.5
10 Female Married 120.5
Step 1

Step 1

The RTRA modified SAS procedure creates the following table:

Table 2
Controlled rounding using sex and marital status
  Married Divorced Widowed Total
Male 361.5 120.5 120.5 602.5
Female 361.5 0.0 241.0 602.5
Total 723.0 120.5 361.5 1,205.0
Step 2

Step 2

The RTRA system applies conventional rounding to the inner cells, and then sums up totals and subtotals.

Table 3
Controlled rounding using sex and marital status
  Married Divorced Widowed Total
Male 362 121 121 603
Female 362 0 241 603
Total 724 121 362 1,207
Step 3

Step 3

The RTRA system sends these counts into the controlled random rounding program. We obtain the following:

Table 4
Controlled rounding using sex and marital status1
  Married Divorced Widowed Total
Male 400 100 100 600
Female 300 0 300 600
Total 700 100 400 1,200

Note that rows and columns are additives. This last table is then sent to the researcher.

Share this page
Date modified: