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

Okay, so I am trying to get the results of proc univariate to export to a microsoft excel sheet. I need multiple ones. Currently, my code is:

 

%macro test2;
        %do i = 1 %to 13;
            %let v = %scan(&varsX,&i.);
            ods html file="testfile.cls";
            proc univariate data=test;
                var &v;
            run;
            ods html close;
        %end;
    %mend test;
    %test2;

 

where my variables are defined in a list above. This prints out a bunch of sheets saved as ASCII files, but I want them all as excel sheets in the same workbook.

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Not tested but some thing like this should get you started:

 

%macro test3;

      ods tagsets.excelxp file="testfile.xlm" options (sheet_interval='PROC');
        %do i = 1 %to 13;
            %let v = %scan(&varsX,&i.);
           
            proc univariate data=test;
                var &v;
            run;
           
        %end;

    ods tagsets.excelxp close;
    %mend test3;
    %test3;

 

The XML file generated can be opended in Excel.

View solution in original post

3 REPLIES 3
ballardw
Super User

Not tested but some thing like this should get you started:

 

%macro test3;

      ods tagsets.excelxp file="testfile.xlm" options (sheet_interval='PROC');
        %do i = 1 %to 13;
            %let v = %scan(&varsX,&i.);
           
            proc univariate data=test;
                var &v;
            run;
           
        %end;

    ods tagsets.excelxp close;
    %mend test3;
    %test3;

 

The XML file generated can be opended in Excel.

jacob_klimek
Obsidian | Level 7

Great, this puts them all in the same file with sheets which is awesome.

 

You have any idea how to keep a title in there because when I run this version of code it drops the titles.

Reeza
Super User
Look at the header/footer, the title should be in there. You can embed the title/footer by looking at the ODS TAGSETS.EXCELXP option - specifically embedded_titles and embedded_footnotes.

See the reference and options available here:
http://support.sas.com/rnd/base/ods/odsmarkup/excelxp_help.html

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 2521 views
  • 1 like
  • 3 in conversation