Thanks for your help guys. Great example of how you can achieve a result in various ways The following code also works as expected: %let COVa_product = product A, product B, product C; %let COVb_price = free, cheep, normal, expensive; %let COVc_quality = low, medium, high; %macro create_prod; proc sql noprint; select name, count(*) into :covs separated by ',', :n_covs from sashelp.vmacro where scope = 'GLOBAL' and prxmatch('/^COV\w_.+$/i',name ) order by name ; quit; %put count: &n_covs; %put covs: &covs; data all (drop=_:); %do i = 1 %to &n_covs; %let cov = %scan(%quote(&covs),&i,','); %let var = %scan(&cov,2,_); length _%scan(&cov,2,_) $ 200 %scan(&cov,2,_) $ 30; _%scan(&cov,2,_) = symget("&cov"); do _i_%scan(&cov,2,_) = 1 to countw(_%scan(&cov,2,_),','); %scan(&cov,2,_) = strip(scan(_%scan(&cov,2,_),_i_%scan(&cov,2,_),',')); *putlog "%scan(&cov,2,_):" %scan(&cov,2,_); %end; output; %do i = 1 %to &n_covs; end; %end; run; %mend; %create_prod;
... View more