BookmarkSubscribeRSS Feed
Deepuu
Calcite | Level 5
Need a Macro to update the values in the Sas dataset automatically if there is an update in excel sheet , if there is no update then the data set should not update. Please help me with code as I am starter. Thank u all!
3 REPLIES 3
ScottBass
Rhodochrosite | Level 12

@Deepuu wrote:
Need a Macro to update the values in the Sas dataset automatically if there is an update in excel sheet , if there is no update then the data set should not update. Please help me with code as I am starter. Thank u all!

 

1) Explain why you need a macro, and what you think that will get you?

 

2) Define "automatically".

 

3) Is your dataset an exact replica of your Excel worksheet?  If so, then just reimport the worksheet and overwrite your dataset.  If not, then add more detail to your question.


Please post your question as a self-contained data step in the form of "have" (source) and "want" (desired results).
I won't contribute to your post if I can't cut-and-paste your syntactically correct code into SAS.
andreas_lds
Jade | Level 19

You will need to

  1. Import the Sheet (=work.sheet)
  2. Compare it with an older and permanently saved version of the dataset (=archive.sheet)
  3. Use the return code of proc compare to decide whether a relevant change was found or not.

Always keep in mind, that using an Excel sheet as data-source is close to the worst decision possible, when deciding about file-types. There are numerous posts explaining the problems that will occur, so i skip that now.

Kurt_Bremser
Super User

Since a change in the spreadsheet might easily cause a change in the structure of the dataset, updates cannot be done (simply) in a reliable way.

You can only rewrite the dataset and try to live with the unpredictable results.

To make such a process sustainable and reliable, you need to cut Excel out of your data processing chain.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 497 views
  • 0 likes
  • 4 in conversation