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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

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