Hello programmers,
I believe this is a minor problem but i can't seem to get my head around it.
I obtained a count from an array and i am trying to use the where statement in the proc print to print only observations with a count of atleast 1 (count is atleast 1 if the patient weighs 230lb).
Here are my codes:
data four; set one;
array weight wt1-wt10;
count=0;
do over weight;
if weight gt 230 then count = count +1;
end;
proc print; var school wt1-wt10;
where wt1=1 and wt2=1 and wt3=1 and wt4=1 and wt5=1 and wt6=1 and wt7=1 and wt8=1 and wt9=1 and wt10=1;
run;
The first part of the code ran but for some reasons, i can't get to print what i specified using proc print.
Any help will be appreciated.
I obtained a count from an array and i am trying to use the where statement in the proc print to print only observations with a count of at least 1
If this is what you want why are you filtering on the WT variables and not the COUNT variable? I think this a logic issue.
In the previous step tou're checking if WT1-WT10 is greater than 230 and I'm guessing that value will never be set to 1 because a weight of 1 isn't really possible.
I think this is what you want.
proc print data=four;
var school wt1-wt10;
where count>1;
run;
@ChuksManuel wrote:
Hello programmers,
I believe this is a minor problem but i can't seem to get my head around it.
I obtained a count from an array and i am trying to use the where statement in the proc print to print only observations with a count of atleast 1 (count is atleast 1 if the patient weighs 230lb).
Here are my codes:
data four; set one;
array weight wt1-wt10;
count=0;
do over weight;
if weight gt 230 then count = count +1;
end;
proc print; var school wt1-wt10;
where wt1=1 and wt2=1 and wt3=1 and wt4=1 and wt5=1 and wt6=1 and wt7=1 and wt8=1 and wt9=1 and wt10=1;
run;
The first part of the code ran but for some reasons, i can't get to print what i specified using proc print.
Any help will be appreciated.
@ChuksManuel wrote:
Hello programmers,
I believe this is a minor problem but i can't seem to get my head around it.
I obtained a count from an array and i am trying to use the where statement in the proc print to print only observations with a count of atleast 1 (count is atleast 1 if the patient weighs 230lb).
Here are my codes:
data four; set one;
array weight wt1-wt10;
count=0;
do over weight;
if weight gt 230 then count = count +1;
end;
proc print; var school wt1-wt10;
where wt1=1 and wt2=1 and wt3=1 and wt4=1 and wt5=1 and wt6=1 and wt7=1 and wt8=1 and wt9=1 and wt10=1;
run;
The first part of the code ran but for some reasons, i can't get to print what i specified using proc print.
Any help will be appreciated.
Show example data and the LOG when you run the proc print. I suspect you get a message :
NOTE: No observations were selected from data set
Since proc print does not do summaries then it is very likely that no single record meets all of those requirements.
Perhaps try OR instead of AND on your where statement. But without example data it is hard to see what you might actually want to do.
Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.
Seems to me like this is what you want
proc print; var school wt1-wt10;
where count ge 1;
run;
I obtained a count from an array and i am trying to use the where statement in the proc print to print only observations with a count of at least 1
If this is what you want why are you filtering on the WT variables and not the COUNT variable? I think this a logic issue.
In the previous step tou're checking if WT1-WT10 is greater than 230 and I'm guessing that value will never be set to 1 because a weight of 1 isn't really possible.
I think this is what you want.
proc print data=four;
var school wt1-wt10;
where count>1;
run;
@ChuksManuel wrote:
Hello programmers,
I believe this is a minor problem but i can't seem to get my head around it.
I obtained a count from an array and i am trying to use the where statement in the proc print to print only observations with a count of atleast 1 (count is atleast 1 if the patient weighs 230lb).
Here are my codes:
data four; set one;
array weight wt1-wt10;
count=0;
do over weight;
if weight gt 230 then count = count +1;
end;
proc print; var school wt1-wt10;
where wt1=1 and wt2=1 and wt3=1 and wt4=1 and wt5=1 and wt6=1 and wt7=1 and wt8=1 and wt9=1 and wt10=1;
run;
The first part of the code ran but for some reasons, i can't get to print what i specified using proc print.
Any help will be appreciated.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.