This is a somewhat complex question, and I hope someone in this forum can help me resolve it without filing a query to support@sas.com. For my book, Visualzing Categorical Data, I wrote a macro, table, to handle common requirements to collapse a frequency table over some factor(s) and/or to apply sas formats to numeric variables so that they could be labeled appropriately in plots. This was needed particularly in plots produced using SAS/IML which reads variables as either numeric or character and cannot apply formats to numeric variables as in SAS procedures. The macro can be found at doc: http://www.datavis.ca/sasmac/table.html source: http://www.datavis.ca/sas/vcd/macros/table.sas I've recently been informed by a user of my book that the macro fails to work when the char=Y option is specified under SAS 9.3, whereas it did work under SAS 9.2. The code I used in the macro to convert numeric variables to character relies on using PROC PRINTTO to write the formatted data to a temporary file and then read it back in in a separate data step. Something changed between SAS 9.2 and SAS 9.3 regarding PROC PRINTTO, but I haven't been able to figure out what. But, perhaps there is another way to accomplish what I want-- to convert numeric variables to formatted character variables in another dataset with the same variable names. When I wrote this macro, the only way to do this I knew of was to use PROC PRINTTO, but I always thought this was a kludge because you could not change a variable from numeric to character in a data step. Demonstration code (using attached data file, berkeley.sas) *include catdata(berkeley); %include 'path/to/berkeley.sas'; *include macros(table); %include 'path/to/table.sas' *-- Collapse over dept; %table(data=berkeley, out=berk2, var=Admit Gender, weight=freq, char=Y, format=admit admit. gender $sex., order=data); Log file from SAS 9.2, where it works: 24 *-- Collapse over dept; 25 %table(data=berkeley, out=berk2, var=Admit Gender, weight=freq, 26 char=Y, format=admit admit. gender $sex., 27 order=data); NOTE: There were 24 observations read from the data set WORK.BERKELEY. NOTE: The data set WORK.BERK2 has 4 observations and 3 variables. NOTE: There were 4 observations read from the data set WORK.BERK2. NOTE: The infile TABLE is: Filename=c:\temp\table.out, RECFM=V,LRECL=120,File Size (bytes)=175, Last Modified=17Feb2012:11:23:59, Create Time=17Feb2012:11:10:11 NOTE: 8 records were read from the infile TABLE. The minimum record length was 0. The maximum record length was 27. NOTE: The data set WORK.BERK2 has 4 observations and 3 variables. Log file from SAS 9.3, where it fails: 80 *-- Collapse over dept; 81 %table(data=berkeley, out=berk2, var=Admit Gender, weight=freq, 82 char=Y, format=admit admit. gender $sex., 83 order=data); NOTE: There were 24 observations read from the data set WORK.BERKELEY. NOTE: The data set WORK.BERK2 has 4 observations and 3 variables. NOTE: There were 4 observations read from the data set WORK.BERK2. NOTE: The infile TABLE is: Filename=c:\temp\table.out, RECFM=V,LRECL=120,File Size (bytes)=0, Last Modified=17Feb2012:11:20:21, Create Time=17Feb2012:11:10:11 NOTE: 0 records were read from the infile TABLE. NOTE: The data set WORK.BERK2 has 0 observations and 3 variables.
... View more