excel - How to export SAS dataset to XLSX, by category, using macro variable? -


I have a large data set, which has around 100 managers, now I have to export data with the manager name so that I There is a dataset for each manager. I am able to use a macro to create a different dataset for each manager (essentially, one category) using code:

 % macro brake (bawl); Data and bawl; Last set (where = (Project_Manager_Name = "& byval")); Run; % improvement; Data_null_; Last set; By Project_Manager_Name; If the first.progress_or_name then execute the call (% nrstr ('% break (' || trim (Project_Manager_Name) || '))); Run;   

This is where I get stuck. I just need the .xlsx files of each and like, the names of the manager at the end of each file name include:

  proc export data = final dbms = outfile xlsx = "& amp; ; Output. \ Final_Report_ManagerName.xlsx "Replace; Run;   

I think I get anywhere in the name outfile & amp; Byval has entered the macro variable, but I still get errors that this reference is not. Any insights?

To use PROC export you must write a macro and call the PROC export 100 times . This is not a great way to use LIBNAME to do the same thing, but instead of 100 export calls, you have 100 dataset names in your data phase and to identify what to do with each manager's data Having 100 selections / When / Output are conditional blocks.

Better ways:

  • If you have 9.4 M1, then you can use ODS Excel to do this. Look at the ODS Excel, and after that you can create a new Sheet for each group using the Sheet_Label option, which can define a sheet name with the variable. This option (as ODS is most of Excel) is similar to ODS TAGSETS.EXCELXP.
  • If you are not, you could use a hash object output method, though still, efficiently to do this a bit more ideally - at least it's a ton of macro programming

    At the end of the day, making an export macro and calling it this way how do you get a% brake macro Call (or, more likely, set the export code inside the brake macro ) Is probably the easiest thing to do, even though it's not exactly ideal (very long periods of time for which you are).

      proc export data = & amp; Byval Dbms = xlsx Outfile = "& amp; Output. \ Final_report_ & amp; Byval..xlsx"; Run;   

    To do this, you need to go inside the% brake macro. You can also skip the data phase in byval and just add one to export, data = Final (where = (Project_Manager_Name = "& byval")).

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -