- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Proc freq data=pg1.np_species;
tables Abundance Conservation_Status;
where species_ID likes”YOSE%” and
Category=“Mammal
run;
proc print data= pg1.np_soecies
Var species _id category scientific _Name common names;
Where species_Id likes “YOSE%” and
Category =“Mammal”;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi and welcome to the communities!
I guess you want to avoid repeating the same statement all over. See this example:
%let wherecond = where species_Id like “YOSE%” and Category = “Mammal”;
proc freq data=pg1.np_species;
tables Abundance Conservation_Status;
&wherecond.;
run;
proc print data= pg1.np_soecies
var species _id category scientific _Name common names;
&wherecond.;
run;
To avoid problems if you do not want a where condition, define the macro variable as empty:
%let wherecond=;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi:
This question is more of a SAS Programming 1 question, not a Data Science question. In the future if you have class questions, you might consider posting them in the forum that we have specfically for Programming 1 students. Here's that link for future reference: https://communities.sas.com/t5/Programming-1-and-2/bd-p/course_discussions .
For the problem that you're working on, our intention is to show students simple uses for macro variables. We start the practice slowly by making sure that the students have coded the correct WHERE statements and have them try the WHERE in 2 different procedures:
Then, after they have working code, we want them to keep going and define macro variables:
The purpose is to show the utility of macro variables and while building an entire WHERE condition is efficient, we didn't include that approach in the beginning Programmign course. We save something like that for the Macro 1 and Macro 2 courses.
Hope this helps explain our approach with this Practice and why there are 2 where statements.
Cynthia