Programming the statistical procedures from SAS

using string text with macro variables

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 5
Accepted Solution

using string text with macro variables

Hi there,

 

i want to use the export funtion while doing regression analyses as follows:

 

    ODS TAGSETS.EXCELXP
    file='H:\Bildung_&x._mitAbi.xls'
    STYLE=minimal
    OPTIONS ( Orientation = 'landscape'
    FitToPage = 'yes'
    Pages_FitWidth = '1'
    Pages_FitHeight = '100' );

 

It is part of an big analysis macro. Is there a way that i can tell SAS that the "&x." in "file='H:\Bildung_&x._mitAbi.xls'" is actualy a macro variable? Its going to be a realy big number of regression analyses and i realy dont want to name the files manualy.

 

Best regards,

Tom


Accepted Solutions
Solution
‎07-05-2016 10:01 AM
Super User
Posts: 5,260

Re: using string text with macro variables

Your program is nearly fine as is. 

 

Single quotes suppress all macro activity.  Use double quotes instead of single quotes around the file path.

View solution in original post


All Replies
Solution
‎07-05-2016 10:01 AM
Super User
Posts: 5,260

Re: using string text with macro variables

Your program is nearly fine as is. 

 

Single quotes suppress all macro activity.  Use double quotes instead of single quotes around the file path.

Contributor
Posts: 34

Re: using string text with macro variables

something like that:

/*1st SOLUTION: using double quote*/
file="H:\Bildung_&x._mitAbi.xls"
    STYLE=minimal
    OPTIONS ( Orientation = 'landscape'
    FitToPage = 'yes'
    Pages_FitWidth = '1'
    Pages_FitHeight = '100' );

/*2nd SOLUTION: resolve the macrovars before*/
%LET X                          =file_xls_name;
%LET FILE_AND_PATH =H:\Bildung_&X._mitAbi.xls;
%PUT &X.;
%PUT &FILE_AND_PATH.;
file="&FILE_AND_PATH."
    STYLE=minimal
    OPTIONS ( Orientation = 'landscape'
    FitToPage = 'yes'
    Pages_FitWidth = '1'
    Pages_FitHeight = '100' );

???

Martino Crippa
Occasional Contributor
Posts: 5

Re: using string text with macro variables

Thanks. That was an easy solution, which spares me from a lot of work. Smiley Happy

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 243 views
  • 2 likes
  • 3 in conversation