BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jpsmith
Fluorite | Level 6

Hello expert SAS data management coders,

I have several dichotomous variables indicating the presence of clinical symptoms (i.e. cough, fever, etc) in an array. I would like to know if patients had "only cough," "only fever," etc. I have put some simplified, example code below with what I would like to happen in [brackets].

 

Hopefully this is a simple question, but if it is complicated, I can look at other routes. But I have had this question in general for a while now and so figured I would go ahead and ask. None of the references I can find on arrays seem to address this specific question.

 

Thank you in advance for your assistance.

Jonathan

 

array x {*} cough malnutrition fever lethargy;
array y {*} cough_only malnutrition_only fever_only lethargy_only 
		do i=1 to dim(x);
			if x{i}=1 and [all other variables in the array equal 0] then y{i}=1; 
else y{I}=0; end; drop i;
1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26
if x{1}=1 and sum(of x{*})=1 then cough_only=1;
if x{2}=1 and sum(of x{*})=1 then malnutrition_only=1;

Or you could do this in a loop where instead of cough_only=1 you have y{1}=1

--
Paige Miller

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26
if x{1}=1 and sum(of x{*})=1 then cough_only=1;
if x{2}=1 and sum(of x{*})=1 then malnutrition_only=1;

Or you could do this in a loop where instead of cough_only=1 you have y{1}=1

--
Paige Miller
jpsmith
Fluorite | Level 6

Perfect - thanks so much! Didn't know about the {*}.

SAS Innovate 2025: Call for Content

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!

Submit your idea!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 573 views
  • 0 likes
  • 2 in conversation