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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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