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!
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.
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.
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.
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.)
What's so bad about a simple %include, if you want to run SAS code stored in a file?
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 ****.
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!
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.