11-24-2017 12:33 PM
I am a very new SAS university edition user, I have a huge table (20 columns, 4 million rows) and I want to filter the table according to one column (say all the values in column 8 should be equal to 334) and then sort the third column Ascendingly.
I can filter and sort the columns by right click on each column and get the results, but I do not know how can I get the table in excel.
Appreciate your help.
This is the code:
CREATE TABLE WORK.query AS
SELECT SHIPMT_ID , ORIG_STATE , ORIG_MA , ORIG_CFS_AREA , DEST_STATE , DEST_MA , DEST_CFS_AREA , NAICS , QUARTER , SCTG , 'MODE'n , SHIPMT_VALUE , SHIPMT_WGHT , SHIPMT_DIST_GC , SHIPMT_DIST_ROUTED , TEMP_CNTL_YN , EXPORT_YN , EXPORT_CNTRY , HAZMAT , WGT_FACTOR FROM _TEMP0.cfs_2012_pumf WHERE NAICS like '%334%';
PROC DATASETS NOLIST NODETAILS;
CONTENTS DATA=WORK.query OUT=WORK.details;
PROC PRINT DATA=WORK.details;
11-24-2017 01:39 PM
Which dataset do you want in EXCEL? Your codes is creating a dataset named QUERY and then using PROC CONTENTS to create another dataset named DETAILS which you then print.
You can use ODS EXCEL to direct the PROC PRINT to an XLSX file. So you could create a file named "myfile.xlsx" with something like this.
ods excel file='/folders/myfolders/myfile.xlsx'; proc print data=details; run; ods excel close;
Or you could just copy the data instead of using PROC PRINT.
libname out '/folders/myfolders/myfile.xlsx'; proc copy inlib=work outlib=out; select details ; run; libname out close;