BookmarkSubscribeRSS Feed
raha_tiny
Calcite | Level 5

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;

2 REPLIES 2
Reeza
Super User

Try a PROC EXPORT. 

 

You can also right click a Table in Libraries and select Export and export the data to your myfolders. 

 

 

 

 

Tom
Super User Tom
Super User

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;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 10779 views
  • 0 likes
  • 3 in conversation