DATA Step, Macro, Functions and more

Macro - Different Data Types in Where Clause

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 14
Accepted Solution

Macro - Different Data Types in Where Clause

I am working with a transaction type data set where there are multiple observations for individual children nested within families.  Each child has a unique" child_id" and an associated "familynumber." I would like to generate a count of the number of children in each family.  I have attempted to use the following code, but I am receiving an error that informs me that there are different data types in the WHERE clause.  Thank you for your help.

proc sql noprint;

select left(put(count(distinct(familynumber)),15.0)) into :fmcount work.time;

select distinct(familynumber) into :family1 - :family&fmcount from work.time;

quit;

%macro family_count;

%do i = 1 %to &fmcount;

proc sql noprint;

select count(distinct(child_id)) from work.time

where familynumber = "&&family&i";

quit;

%end;

%mend family_count;

%family_count;


Accepted Solutions
Solution
‎10-07-2014 03:08 PM
Super User
Posts: 3,260

Re: Macro - Different Data Types in Where Clause

Posted in reply to PhillipSherlock

Is the familynumber column numeric? If so: where familynumber = &&family&i;

View solution in original post


All Replies
Solution
‎10-07-2014 03:08 PM
Super User
Posts: 3,260

Re: Macro - Different Data Types in Where Clause

Posted in reply to PhillipSherlock

Is the familynumber column numeric? If so: where familynumber = &&family&i;

🔒 This topic is solved and locked.

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

Discussion stats
  • 1 reply
  • 163 views
  • 0 likes
  • 2 in conversation