user5768866
user5768866

Reputation:

SAS reading from a dataset then write to Excel

Below is the sas code to read some data from a dataset, then write the data to an excel file, however, there is some problem.

LIBNAME mck_pred "N:\Data-Dump\test\training" compress=yes;

proc sql;
create table temp as 
select cust_id, number from mck_pred.pred_data;
quit;

proc export data=temp output="C:\Users\test.xlsx" dbms=XLSX replace;
run;

the error shows:

OTE: The SAS System stopped processing this step because of errors.
2463  proc export  data=temp output="C:\Users\test.xlsx" dbms=XLSX replace;
                                      ------
                                      22
                                      76
ERROR 22-322: Syntax error, expecting one of the following: ;, (, DATA, DBLABEL, DBMS, DEBUG, FILE,
              LABEL, OUTFILE, OUTTABLE, REPLACE, TABLE, _DEBUG_.

ERROR 76-322: Syntax error, statement will be ignored.

2464  run;

Regarding the code as shown, I have three problems:

  1. what does compress=yes mean?
  2. How to change the program so that it could run successfully?
  3. When should we use quit and run in the program?

Thanks.

Upvotes: 0

Views: 340

Answers (1)

user2877959
user2877959

Reputation: 1792

1) compress=yes means that new datasets you create in library mck_pred will have their observations compressed. In this particular example, it has no impact.

3) To make a long story short, quit is used with proc sql, run is used with data steps and all other SAS procedures.

2) The syntax for the output path is outfile=, not output=. You should also mention dbms=xlsx on your proc export statement.

Upvotes: 2

Related Questions