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

Hi

Can anyone of you run the following code and attached the data set it generate?This is from the article attached url -page # 4 My SAS is expired and now in proceed of renewing the licence.I would like to learn in depth about this article until I get my licence renewed.

Thant would be great help

Options mprint mlogic sympblegen;
%macro generate(EmpCount =%str()
,AvgCoLambda=
,UserGrpLambda=
,MaxRepeats= );
data CallsPerHour;
/*Assume base rate is in hour per 1000 Emps*/
do emps= &EmpCount;
do repeats=1 to &MaxRepeats;
/*Average company*/
CoType="Avg ";
EmpsAtCo=emps;
calls=rand('POISSON',&AvgCoLambda);
output;
/*Average company with user group*/
CoType="AvgWUserGroup";
EmpsAtCo=emps;
calls=rand('POISSON',&UserGrpLambda);
output;
/*you can add additional company types here*/
/*A consulting company?-w/ a different lambda*/
end; /*do repeats=1 to 5;*/
end; /*do emps= & EmpCount;*/
run;
proc greplay nofs IGOut=GSeg;
delete _all_;
quit;;
proc univariate data=CallsPerHour normal;
var calls;
/* freq calls;*/
histogram calls /midpoints =1 to 20 by 1;;
run;
Proc sort data=CallsPerHour;
by CoType emps;
run;
s

https://www.lexjansen.com/nesug/nesug10/sa/sa04.pdf

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

I can't explain what the code is supposed to do.  I leave that part to you.  But I can give you some guidance on how to turn this into something you can run and play with.

 

Get rid of the macro language.  So the %macro statement and %mend statements get removed.

 

Any time you see &, replace that with a reasonable value.  For example, the code contains:

 

do Emp = &EmpCount;

 

Replace that, possibly with:

 

do Emp = 1000, 3000, 5000, 10000;

 

The code also contains:

 

do repeats = 1 to &MaxRepeats;

 

Replace that, possibly with:

 

do repeats = 1 to 50;

 

The code contains:

 

calls = rand("POISSON", &userGrpLambda);

 

Replace that, possibly with:

 

calls = rand("POISSON", 5);

 

Similarly, try replacing &AvgCoLambda with 8.

 

I can't tell you what values to use.  But choosing reasonable values and replacing the macro language will give you a look at what the program is supposed to do.

View solution in original post

10 REPLIES 10
Reeza
Super User
You can sign up for SAS Academics on Demand for free, which is cloud based or you can use SAS University Edition. If this is commercial usage, we would be breaking rules so you can do that on your own.
chuie
Quartz | Level 8

Reeza, This is not for any commercial use . I am genuinely asking for help and I would like to at least  prepare for my data the way it is in this article.I hope you understand my situation.

Reeza
Super User

Then you can use Academics on Demand. Any reason you can't do that?

 

EDIT: you do not need to be in University or an 'academic' to use either SAS University Edition or Academics on Demand (independent learner). You can access it here:

https://www.sas.com/en_us/software/on-demand-for-academics.html

 

or SAS UE here:

https://www.sas.com/en_us/software/university-edition.html


@chuie wrote:

Reeza, This is not for any commercial use . I am genuinely asking for help and I would like to at least  prepare for my data the way it is in this article.I hope you understand my situation.


 

chuie
Quartz | Level 8
i could but I will have sas anyway in few days... This ask was just to follow along to the article and to do that I need to understand the dataset layout.If I could have option to wait then why would I work on sunday evening 🙂 ( plus 20 months son)
Astounding
PROC Star
This code does nothing. It is the beginning of a macro definition. For the code to do anything, the definition would need to be completed, and the macro would need to be called, with values supplied for the macro parameters.
Reeza
Super User
The rest of the code is on the next page of the article, OP only copied the first portion but the article has the full code.
chuie
Quartz | Level 8

Thank you Astounding. I am no knowledge of macro so I do not know. The article says that this is the code used to generate the data used in this article. If you could just give me how the data is arranged with the variable name used  in the code above that would be very very helpful to follow along the article and to do same analysis using my data.

So based on the code below, it looks like we just need three variables, 1. cotype, 2. emps and 3. calls

is this as simple as :

cotype    emps               calls

a            50                     120

b           200                    130

... and so one?

 

proc univariate data=CallsPerHour normal;
by CoType emps;
var calls;
histogram calls /midpoints =1 to 15 by 1;
run;
run; %mend generate;
%generate(EmpCount=%str(1000, 3000, 5000,10000 )
,AvgCoLambda=8
,UserGrpLambda=5
,MaxRepeats=50 );

Astounding
PROC Star

I can't explain what the code is supposed to do.  I leave that part to you.  But I can give you some guidance on how to turn this into something you can run and play with.

 

Get rid of the macro language.  So the %macro statement and %mend statements get removed.

 

Any time you see &, replace that with a reasonable value.  For example, the code contains:

 

do Emp = &EmpCount;

 

Replace that, possibly with:

 

do Emp = 1000, 3000, 5000, 10000;

 

The code also contains:

 

do repeats = 1 to &MaxRepeats;

 

Replace that, possibly with:

 

do repeats = 1 to 50;

 

The code contains:

 

calls = rand("POISSON", &userGrpLambda);

 

Replace that, possibly with:

 

calls = rand("POISSON", 5);

 

Similarly, try replacing &AvgCoLambda with 8.

 

I can't tell you what values to use.  But choosing reasonable values and replacing the macro language will give you a look at what the program is supposed to do.

chuie
Quartz | Level 8

Great guidance Astounding. It might help me move forward to the article n my  data prep. I sent my friend to run it and she said it works.

Thank you so very much 

chuie
Quartz | Level 8
Also i have reached out to author and have not heard back from him yet.

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
  • 10 replies
  • 1573 views
  • 2 likes
  • 3 in conversation