A trick can be to use separated by to automatically trim the value, which will work regardless of a numeric or character value. SELECT max(maxi) into : n separated by ' ' from ( select id_var, count(*) as maxi from prim_tab); QUIT; And following onto Richards example, strip() would work just as well. Regardless, it may not be a bad idea to use a put() statement to control the data value format being stored in the macro variable. Have attached some examples as the effect is interesting and all the extra spaces in ex3 is not a typo. . proc sql noprint; select max(age) into: ex1 from sashelp.class ; select max(age) into: ex2 separated by ' ' from sashelp.class ; select cats(max(age)) into: ex3 from sashelp.class ; select put(max(age), 8.-L) into: ex4 from sashelp.class ; quit; %put [&ex1]; %put [&ex2]; %put [&ex3]; %put [&ex4]; Would give the following in the log 32 proc sql noprint; 33 select max(age) into: ex1 from sashelp.class ; 34 select max(age) into: ex2 separated by ' ' from sashelp.class ; 35 select cats(max(age)) into: ex3 from sashelp.class ; 36 select put(max(age), 8.-L) into: ex4 from sashelp.class ; 37 38 quit; NOTE: PROCEDURE SQL used (Total process time): real time 0.01 seconds cpu time 0.01 seconds 39 40 %put [&ex1]; [ 16] 41 %put [&ex2]; [16] 42 %put [&ex3]; [16 ] 43 %put [&ex4]; [16 ] HTH
... View more