## Need help creating indicator variable (learning SAS)

Solved
Occasional Contributor
Posts: 7

# Need help creating indicator variable (learning SAS)

[ Edited ]

Hi,

I am new to SAS and have just started by learning journey. I am not able to understand the below question I am given in my class.

Can someone please explain me and also guide me what is to be done in this.

The data to be used is Sashelp. Demographics.

"Create an indicator for adult literacy rate percentage with cutoff points at 90% and 50%. Then create a table report to show total population, average population annual growth rate percentage and average population in urban areas percentage for each region and your indicator level"

Accepted Solutions
Solution
Tuesday
SAS Super FREQ
Posts: 4,238

## Re: Not able to understand the question.Need help

Welcome to SAS. As others have said, it is always a good idea to work with classmates and teachers because they will help you to relate the assignment to topics you have covered in the course.

The part that is probably stumping you is "how do I create an indicator variable." Recall that an indicator variable is a categorical variable. You can show the levels to be numeric (., 1, 2, 3) or character (" ", "Low", "Medium", "High").  The following code gives you a hint on one way to create an indicator variable for these data:

``````data Want;
length LiteracyIndicator \$6;
set Sashelp.Demographics;
LiteracyIndicator = " ";
else if 0 <= AdultLiteracypct < 0.5 then
LiteracyIndicator  = "Low";
else if 0.5 <= AdultLiteracypct < 0.9 then
LiteracyIndicator = "Medium";
else
LiteracyIndicator = "High";
run;

``````

Now that you have an indicator variable, how can you create the report? I let you ponder that question!

Incidentally, this problem can be solved without explicitly creating an indicator variable by using a concept known as "SAS formats."  Ask your teacher about them!

All Replies
PROC Star
Posts: 1,265

## Re: Not able to understand the question.Need help

What have you tried so far?

Super User
Posts: 5,876

## Re: Not able to understand the question.Need help

1. What part of the don't you understand?
2. Class specific questions are best answered in your class, not here.
Data never sleeps
Occasional Contributor
Posts: 7

## Re: Not able to understand the question.Need help

Thank you
Occasional Contributor
Posts: 7

Solution
Tuesday
SAS Super FREQ
Posts: 4,238

## Re: Not able to understand the question.Need help

Welcome to SAS. As others have said, it is always a good idea to work with classmates and teachers because they will help you to relate the assignment to topics you have covered in the course.

The part that is probably stumping you is "how do I create an indicator variable." Recall that an indicator variable is a categorical variable. You can show the levels to be numeric (., 1, 2, 3) or character (" ", "Low", "Medium", "High").  The following code gives you a hint on one way to create an indicator variable for these data:

``````data Want;
length LiteracyIndicator \$6;
set Sashelp.Demographics;
LiteracyIndicator = " ";
else if 0 <= AdultLiteracypct < 0.5 then
LiteracyIndicator  = "Low";
else if 0.5 <= AdultLiteracypct < 0.9 then
LiteracyIndicator = "Medium";
else
LiteracyIndicator = "High";
run;

``````

Now that you have an indicator variable, how can you create the report? I let you ponder that question!

Incidentally, this problem can be solved without explicitly creating an indicator variable by using a concept known as "SAS formats."  Ask your teacher about them!

Occasional Contributor
Posts: 7

## Re: Not able to understand the question.Need help

Many Thanks

☑ This topic is solved.