BookmarkSubscribeRSS Feed
CurtisMack
Fluorite | Level 6
Hi all,

Here is some behaviour I didn't expect:

proc sql ;
create table junk as
select * from NewPremises(firstobs = 5 obs=5);
update NewPremises(firstobs = 5 obs=5) set PremisesId = 99;
quit;
----------------------------------
9185 proc sql ;
9186 create table junk as
9187 select * from NewPremises(firstobs = 5 obs=5);
NOTE: Table WORK.JUNK created, with 1 rows and 8 columns.

9188 update NewPremises(firstobs = 5 obs=5) set PremisesId = 99;
NOTE: 52798 rows were updated in WORK.NEWPREMISES.

9189 quit;
-------------------------------------------

Why does the Update statement ignore the FIRSTOBS and OBS statment and update the entire dataset, but the select statement works as I expected?

Also, does anybody know of a way to update a row based on it's row number?

I appreciate any insight you may have.
Curtis
3 REPLIES 3
DanielSantos
Barite | Level 11
FIRSTOBS and OBS are input options (read).

See the DETAILS section of the online doc:
http://support.sas.com/documentation/cdl/en/lrdict/62618/HTML/default/a000131129.htm

Cheers from Portugal.

Daniel Santos @ www.cgd.pt
LinusH
Tourmaline | Level 20
The only efficient way to update y row number in SAS as far as I know is using the data step, MODIFY and POINT.

/Linus
Data never sleeps
CurtisMack
Fluorite | Level 6
Thanks for both of your replies. It confirms my suspisions that there is no way to do this in PROC SQL. I use MODIFY in most of my DB processing, but in the particular solution I am working on, I am stuck in SQL. I have found an inellegant solution that I will just have to live with.
Thanks Again!

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
  • 3 replies
  • 1135 views
  • 0 likes
  • 3 in conversation