Export variable types in a SAS dataset

Is there any easy way to capture and export the type of each variable in a SAS dataset? I export the data set to CSV format for reading in R, and the procedure read.tablein the latter case can work more efficiently if it also knows the data type of each variable.

+3
source share
1 answer

PROC CONTENTS has an OUT = parameter to output a dataset with variable attributes. type = 1 is numeric, and type = 2 is a character. NTN.

   proc contents data=sashelp.class out=vars;
   run;

   proc print data=vars noobs;
     var varnum name type length;
   run;
   /* on lst
   VARNUM    NAME      TYPE    LENGTH

      3      Age         1        8
      4      Height      1        8
      1      Name        2        8
      2      Sex         2        1
      5      Weight      1        8
   */
+2
source

Source: https://habr.com/ru/post/1781376/


All Articles