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

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 value:(

 

 

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;

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

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

4 REPLIES 4
Reeza
Super User

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.

Dd07
Fluorite | Level 6

thankyou Reeza,

 

Astounding
PROC Star

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.

 

Dd07
Fluorite | Level 6

yeah my mistake i forgot to mention $ 😞

 

Thankyou Astounding ..you are awesome.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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