DATA Step, Macro, Functions and more

Need help creating indicator variable (learning SAS)

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 7
Accepted Solution

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;
if AdultLiteracypct = . then 
   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!

View solution in original post


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

Re: Not able to understand the question.Need help

For your encouragement
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;
if AdultLiteracypct = . then 
   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 Smiley Happy

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 152 views
  • 2 likes
  • 4 in conversation