BookmarkSubscribeRSS Feed
irisG
Calcite | Level 5

I understand that SAS can easily import excel data and treat it as SAS data set. However, if I just need one value from excel and use that value as a SAS variable. Is it possible? How do I go about doing that? Thanks!

 

7 REPLIES 7
Jagadishkatam
Amethyst | Level 16
You can use the same proc import procedure as below

proc import datafile='path of excel' out=sasdataset dbms=excel replace;
run;
Thanks,
Jag
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Of what benefit is keeping one value in an Excel file to use in SAS?  There are many ways to get data into SAS.  You could just type it in at the top of the program:

% let thevalue=abc;

You could have prompts etc.

irisG
Calcite | Level 5

I am toying with automating part of the process that currently involve talking to an excel spreadsheet and reiterating the calculation. Right now we are using the same solution as you suggested but I wonder whether there are ways to improve the process.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Well, the biggest improvement to the process would be to drop SAS or Excel.  Fewer tools in the process always makes for a simpler, easier process.  For instance, what is Excel needed?  Can it not be stored as a SAS dataset, then output to Excel at the end of the process?  What is SAS needed for, if you have an Excel file which needs updating, update it using VBA which is inbuilt into Excel.  Either scenario halves the tools and probably the effort.

irisG
Calcite | Level 5

That's definitely a tidier solution. I am trying to fact find at this stage to see what different approaches are available. One idea was to call the SAS code from VBA but our issue is that the code is too long if I use the Jointext function to join all the code (this is what I saw as one of the solutions, by puting a code in a named cell and then execute the SAS code from VBA.)

Kurt_Bremser
Super User

If that value is just typed into a spreadsheet by somebody, have them type it into a SAS prompt instead and spare yourself the hassle of dealing with the Excel ****.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 7 replies
  • 1056 views
  • 0 likes
  • 4 in conversation