DATA Step, Macro, Functions and more

compare 2 set of array with each has 3 varibale

Accepted Solution Solved
Reply
Contributor
Posts: 35
Accepted Solution

compare 2 set of array with each has 3 varibale

Hello Everyone,

 

Please suggest me and correct me why my flag(match1,match2 and match3) is showing as missing value.

i just need if the Freq_hist_201210 data matches Source_201210 then mark match1 as true else false

again if Freq_hist_201211 data matches Source_201211 then mark match2 as false and so on.

 

In my coding it is giving missing valueSmiley Sad

 

 

data val;
infile datalines;
input hist $16. Source $14.;
datalines;
Freq_hist_201210  Source_201210
Freq_hist_201211  Source_201211
Freq_hist_201212 Source_201212
;
run;
Proc sql;
select hist into : a separated by ' ' from val;
select Source into : b separated by ' ' from val;quit;
%put &a. &b.;


Data validation;
set summary2;
Array aa(*) &a.;
Array bb(*) &b.;
Array match(3) ;
Do i=1 to dim(aa);
if aa(i)=bb(i) then match(i)="true";
else match(i)= "false";
end;


run;


Accepted Solutions
Solution
‎03-03-2016 02:45 PM
Super User
Posts: 5,082

Re: compare 2 set of array with each has 3 varibale

All the variables are numeric, including Match1, Match2, and Match3.  So they can't hold "true" or "false".  Try defining them as character instead:

 

array match {3} $ 5;

 

And be sure to pay attention to the log when it talks about character to numeric conversion.  That can be a clue.

 

View solution in original post


All Replies
Super User
Posts: 17,829

Re: compare 2 set of array with each has 3 varibale

Are these numerical variables? What does the log say, and what does your data look like?

 

My guess - numerical precision mismatch - maybe need to round?

 

Verify your macro variables are resolving properly. Hard code it in, if necessary, and test it.

Contributor
Posts: 35

Re: compare 2 set of array with each has 3 varibale

thankyou Reeza,

 

Solution
‎03-03-2016 02:45 PM
Super User
Posts: 5,082

Re: compare 2 set of array with each has 3 varibale

All the variables are numeric, including Match1, Match2, and Match3.  So they can't hold "true" or "false".  Try defining them as character instead:

 

array match {3} $ 5;

 

And be sure to pay attention to the log when it talks about character to numeric conversion.  That can be a clue.

 

Contributor
Posts: 35

Re: compare 2 set of array with each has 3 varibale

yeah my mistake i forgot to mention $ Smiley Sad

 

Thankyou Astounding ..you are awesome.

☑ This topic is SOLVED.

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

Discussion stats
  • 4 replies
  • 253 views
  • 2 likes
  • 3 in conversation