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

hi..i want to update specific excel cells from sas using Proc sql..is it possible??

if yes, i need to update range of excel values using proc sql...i dont want to use SAS-DDE..means dont want to open excel file from sas..rather i just  can connect to excel through proc sql...

finally am struggling to how to give range of excel cell in proc sql to so that i can put data in excel from sas..?ls

1 ACCEPTED SOLUTION

Accepted Solutions
bnarang
Calcite | Level 5

You can create library and map this excel file in the library. Further, you can modify once the datasheets are visible as datasets using PROC SQL.

View solution in original post

8 REPLIES 8
bnarang
Calcite | Level 5

You can create library and map this excel file in the library. Further, you can modify once the datasheets are visible as datasets using PROC SQL.

RaviSPR
Obsidian | Level 7

Thank-You...

i think we need to use Named range also in the excel files.

Ksharp
Super User

As above said.

Once you assign a libname to the excel file successfully, You can modify cell like a sas dataset.

libname x excel 'D:\x.xls' scantext=no;

proc sql;

update x.'Sheet1$'n

set _col0='xxx'

  where _col2='my condition';

  quit;

Ksharp

RaviSPR
Obsidian | Level 7

Thanks a lot...

yes. its correct.

i got a way to write data to specific excel cells.But am getting variable names into the xl file those i dont want.

below is the code.

Here namedrng1 is the Named range in the excel file contains specific cells in a sheet.

Libname xl excel "Path";

Data xl.namedrng1;

set work.emp;

run;

here am getting columns names into xl file..is there any way to remove sas dataset's(work.emp) column names?

I can hide these columns in the excel file...BUT....still....????

Regards,

SPR.

Ksharp
Super User

If your excel file is in english, try to use XLS engine.

proc export data=sashelp.class outfile='c:\want.xls' replace dbms=xls;

putnames=no;run;

Ksharp

RaviSPR
Obsidian | Level 7

Sorry Ksharp. if we use proc export we cant write data to required cell ranges in the excel...!! right??

is any further add-ons for my code which i mentioned above.i.e Libname and Proc SQL connect to excel, to eliminate column names while writing data into the cell ranges??

Thanks a lot.

Ksharp
Super User

My SQL 's update statement will not get extra variable name . Did you try it ?

RaviSPR
Obsidian | Level 7

But your code writes the data by checking condition with the excel cell values.

Actually, i want to write/export data which is coming from sas datasteps. so, i cant check the conditions with the values presented in the excel.

i.e its entirely new data for the new month which should be written to excel excel cell ranges.

The problem here is unwanted column ranges..But for time being i am hiding those columns in the template file.

Thanks,

SPR.

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!

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
  • 8 replies
  • 4818 views
  • 4 likes
  • 3 in conversation