BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
HB
Barite | Level 11 HB
Barite | Level 11

Hey,

I have this.  It works.

LIBNAME MYXLS "K:\hb_progs\match_excel\a_RPT_120318.XLS";

PROC DATASETS LIB=MYXLS;
DELETE 'report'n;
RUN;
QUIT;

proc sql;
create table myxls.report as
select distinct hsdis,
(select count(thing1)
from HSCLISIR
where thing1=1 and hsdis='a')
as t1,
(select count(thing2)
from HSCLISIR
where thing1=0 and hsdis='a')
as t0,

...goes on for awhile with a bunch of counts of different things...

from hsclisir

where hsdis='a';

This makes an one row multiple column Excel file that I'm trying to make into a mail merge source.  Each row will becone an entity.

Aside from the fact that I think there is a better way to do this, what I want to do right at the moment is the same proc sql but for hsdis entity b.  There are like 40 entities but that is anoter story.

What I think I want is a PROC APPEND somewhere.  I use the PROC DATASETS with the delete because if you don't use the delete and the Excel file already exists (it will, the report will be run multiple times) then SAS blows up and won't write.  What I want to do is append the info for b, then for c, etc. 

I can't see syntax that looks hopeful.

proc append base=myxls

data = what to put here???

second PROC SQL starts to make data to be appended

Maybe the second (and subsequent) PROC SQL's have to INSERT INTO instead of CREATEing???

Your gentle guidance is humbly requested.

UPDATE:

Following my own suggestion, I tried

proc sql;

INSERT INTO myxls.report ( etc etc

for the second SQL statment.

The SQL doesn't throw any errors but I get

ERROR: No Update/Append allowed. Set libname option SCAN_TEXT=NO to enable Update and Append operation.

So I added that:

LIBNAME MYXLS "K:\hb_progs\match_excel\a_RPT_120318.XLS" SCAN_TEXT=NO;

but no joy.

Hmmmmm.

1 ACCEPTED SOLUTION

Accepted Solutions
HB
Barite | Level 11 HB
Barite | Level 11

HAH!!!

Miller time!

I set SCAN_TEXT=NO on the wrong LIB call.  Put it on the correct one and it works a treat.

Now it builds the Excel file row by row.   Okay.  I'll be back with another question.  I am doing what I am doing as a clunky quick fix.  I still want to do it right. 

View solution in original post

1 REPLY 1
HB
Barite | Level 11 HB
Barite | Level 11

HAH!!!

Miller time!

I set SCAN_TEXT=NO on the wrong LIB call.  Put it on the correct one and it works a treat.

Now it builds the Excel file row by row.   Okay.  I'll be back with another question.  I am doing what I am doing as a clunky quick fix.  I still want to do it right. 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 1 reply
  • 1419 views
  • 0 likes
  • 1 in conversation