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

Hi all,

I am trying to create a Web Stored Process that uses a single sourcefile to create different reports.

I would imagine I'd need different Macros for each datastep, like below.

 

libname sourcefile 'SingleSourceFile';

run;

 

data &one;

set sourcefile;

where b=1;

run;

 

data &two;

set sourcefile;

where b=2;

run;

 

data &three;

set sourcefile;

where b=3;

run;

 

 

The Stored Process will ask user to select report to run and point and run a datastep based on what the Macro Varible.

 

If possible, can someone point me to any resouce that I can use to create this solution.

 

Thanks for your help all.

 

Ruzvmun

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
FredrikE
Rhodochrosite | Level 12

You might want to use a macro statement that checks what the user want and then select which report to create?!

 

 

Lets say you have a prompt called reportSelection and it contains two reports -R1 and R2.

 

As an example STP code could look something like:

 

%macro select_report();

  %if &reportSelection = R1 %then %do;

    data out;

       set sourcefile;

       where b = 1;

    run;

 

    proc tabulate data=out;

       ......

      .....

   run;

 

  %end;

 

  %if &reportSelection = R2 %then %do;

    data out;

       set sourcefile;

       where b = 2;

    run;

   proc print data=out;

   run;

  %end;

 

 

 

%mend;

%select_report;

 

Two different data selections and different outputs 🙂

 

//fredrik

View solution in original post

4 REPLIES 4
Tom
Super User Tom
Super User

I don't understand the question. If you want a single program to generate multiple reports why not just code the program to generate multiple reports?

Are you asking how to make the program conditionally generate only some of the reports based on the user's choice?

ruzvmun
Calcite | Level 5

Hi Tom,

Yes...based on prompt user selects, run specific data step and leave out the rest. Does that make sense.

I apologize for the confustion, still a SAS novice.

FredrikE
Rhodochrosite | Level 12

You might want to use a macro statement that checks what the user want and then select which report to create?!

 

 

Lets say you have a prompt called reportSelection and it contains two reports -R1 and R2.

 

As an example STP code could look something like:

 

%macro select_report();

  %if &reportSelection = R1 %then %do;

    data out;

       set sourcefile;

       where b = 1;

    run;

 

    proc tabulate data=out;

       ......

      .....

   run;

 

  %end;

 

  %if &reportSelection = R2 %then %do;

    data out;

       set sourcefile;

       where b = 2;

    run;

   proc print data=out;

   run;

  %end;

 

 

 

%mend;

%select_report;

 

Two different data selections and different outputs 🙂

 

//fredrik

ruzvmun
Calcite | Level 5

Thank you Fred,

this worked and now I Boss is happy:)

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
  • 4 replies
  • 1461 views
  • 0 likes
  • 3 in conversation