Hi Tom, Thank you for your quick response. I have followed similar steps, Data Sales; Name $ Product $ Sales1 Sales2 Sales3; datalines; aaa xxxxx 0 0 200 dfrt iiiiiiiii 03 05 65 ertttt pxxdfd 55 0 0 ; /*START OF MACRO*/ %macro dsn(t=,NME=); %let cnt = %sysfunc(countw(&t.)); %do i = 1 %to &cnt.; %let v&i. = %sysfunc(scan(&t.,&i.)); %put &&v&i.; %if %trim(&&v&i.) ne 0 /*OR %trim(&&v&i.) NE %str()*/ %then %do; %let ite =&i.; %put valueM&i.====>>>> &&v&i.; %put SLS&i.====>>>> SLS_&i.; /*IM TRYING TO CREATE THE DATASET WHERE SALES IS NOT 0*/ data SLS_&ite.; SLS_&ite. = &&v&i.; run; %end; /* THE ELSE; IS ONLY PUTTING SALES 0 VALUES FOR THE PRODUCTS*/ %else %do; %let ite = %sysevalf (&i. + 1); %put cnt&ite.===>> &&ite.; %let v&ite. = %sysfunc(scan(&t.,&ite.)); %put &&v&ite.; %put SLS&i.====>>>>SLS_&ite.; %put VALUE&i.====>>>> &&v&ite.; %end; %end; %mend; %dsn(t= 0 0 10, SALES1); The above code ignores the 0 and i becomes i+1 when it finds a non zero. for example %dsn(t= 0 40 14, SALES1); MLOGIC(BTL_DETAILS): %DO loop index variable I is now 2; loop will iterate again. SYMBOLGEN: Macro variable I resolves to 2 MLOGIC(BTL_DETAILS): %LET (variable name is V2) SYMBOLGEN: Macro variable T resolves to 0 40 14 14 SYMBOLGEN: Macro variable I resolves to 2 MLOGIC(BTL_DETAILS): %PUT &&V&i. SYMBOLGEN: && resolves to &. SYMBOLGEN: Macro variable I resolves to 2 SYMBOLGEN: Macro variable V2 resolves to 40 40 MLOGIC(TRIM): Beginning execution. SYMBOLGEN: && resolves to &. SYMBOLGEN: Macro variable I resolves to 2 SYMBOLGEN: Macro variable V2 resolves to 40 MLOGIC(TRIM): Parameter VALUE has value 40 MLOGIC(TRIM): %LOCAL I SYMBOLGEN: Macro variable VALUE resolves to 40 now 40 is value for SALE3 , if i assign the value of SALE3 to i = 1 then it will be an issue reports hence i want to create a dataset when i value is not 0 and we are not sure how many values will be there and in which order with 0's or without 0's. Apologies for any confusion created.
... View more