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;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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