Hi SAS users,
I need help with the below error (wrong output). I am trying to build the select variables based on the fld values that are being passed in the parameter. I tried alias but still i am unable to get the right values.
fld has 2 values with pipe delimeter and i am looking for SQL to build the below way.
select distinct ID , NAME from from &input_dataset
CODE is as below -
%macro util_macro_insert (fld=,Input_Dataset=,Var_Util= , Output_Dataset=); %let fld_cnt = %sysevalf(%sysfunc(COUNTC(&fld,|))+1); %put &=fld_cnt; proc sql; create table &Output_Dataset. as select distinct %DO i=1 %to &fld_cnt; %if &i = 1 %then %do; trim(%scan(&fld,&i,|)) %end; %if &i > 1 %then %do ; ,trim(%scan(&fld,&i,|)) %end; %END; from &input_dataset ; Quit; %mend util_macro_insert;
%util_macro_insert (fld=ID | name,Input_Dataset=test1,Var_Util=NBR, Output_dataset =output );
ERROR : I am getting _TEMA001 and _TEMA002 instead of ID & NAME.
Thanks,
Ana
... View more