SAS Code to Find Unique Values of All Variables in a Dataset
To get the unique values of all variables in a dataset, you can use the PROC FREQ procedure in SAS. Here's an example code:
/* Create a sample dataset */
data mydata;
input var1 $ var2 var3;
datalines;
A 1 10
B 2 20
C 3 30
D 4 40
A 1 10
;
run;
/* Use PROC FREQ to get unique values of all variables */
proc freq data=mydata;
tables _all_ / noprint out=unique_values;
run;
/* Print the unique values */
proc print data=unique_values;
run;
In this code, we first create a sample dataset called 'mydata' with three variables: var1, var2, and var3. We then use the PROC FREQ procedure to get the unique values of all variables in the dataset. The 'all' option tells SAS to include all variables in the tables statement. We also specify the 'noprint' option to suppress the output table. Instead, we use the 'out' option to create a new dataset called 'unique_values' containing the unique values of all variables. Finally, we use the PROC PRINT procedure to display the 'unique_values' dataset.
原文地址: http://www.cveoy.top/t/topic/ovsh 著作权归作者所有。请勿转载和采集!