Hi there, I would be really thankfull if you can help me with following query. I have customer list with their numbers of transactions(No of Invoices) and their spend. And I want select 10% random customers from this sample which have almost 10% spend and transactions (taking 9 to 11% to get a solution). Basically I want to keep on creating the random samples untill my conditions are met. Following is the code. %let Trans_Ratio=1; %let Spend_Ratio=1; %do %until(0.09<=Trans_Ratio<=0.11 %and 0.09<=Spend_Ratio<=0.11); proc surveyselect data=All_data samprate=0.1 method=srs out=Sample_data; run; proc sql; select sum(NoOfInvoices) into : Sample_Invoice from Sample_data; select sum(Revenue) into : Sample_Spend from Sample_data; select sum(NoOfInvoices) into : Tot_Invoice from All_data; select sum(Revenue) into : Tot_Spend from All_data; quit; %let Trans_Ratio=%sysevalf(&Sample_Invoice./&Tot_Invoice.); %let Spend_Ratio=%sysevalf(&Sample_Spend./&Tot_Spend.); %end; But the problem is that the loop is running even if the condtitions(0.09<=Trans_Ratio<=0.11 %and 0.09<=Spend_Ratio<=0.11) are met. SYMBOLGEN: Macro variable TRANS_RATIO resolves to 0.09950702848001 SYMBOLGEN: Macro variable SPEND_RATIO resolves to 0.10113175882141 MLOGIC(TG_CREATION): %IF condition ((0.09<=&Trans_Ratio.<=0.11) %and (0.09<=&Spend_Ratio.<=0.11)) is FALSE Not sure why the if statment is FALSE. Thanks in advance, Shailendra
... View more