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:
PROC SQL;
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%';
RUN;
QUIT;
PROC DATASETS NOLIST NODETAILS;
CONTENTS DATA=WORK.query OUT=WORK.details;
RUN;
PROC PRINT DATA=WORK.details;
RUN;
Try a PROC EXPORT.
You can also right click a Table in Libraries and select Export and export the data to your myfolders.
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;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.