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

Dear community,

 

I would be very glad, if you could help concerning the following issue.

Please consider the following table (as also attached as sas7bdat) I am faced with

Have.PNG

, as well as the table I do want to end up with:

Want.PNG

 

The scenario, thus, is the following:

I have a table with companies. This table contains "beginning_date" as well as "ending_date" - this variables define, from "when to when" the row-information hold valid. As an example, I added information towards the "quality" of the offered product.

Object of interest is the "manager" - I want to end up with a data set, listing up

which manager

works in which time span

for which company, i.e.:

List.PNG.

 

"Tom" at "Mario's Apples" is the problem -

I cannot just simply take

proc means data=have noprint;
	output out=list (drop = _FREQ_ _TYPE_)
	min(beginning_date)	=	beg_date_manager
	max(ending_date)		=	end_date_manager;
	by
		company
		Manager;
run;

, because then it would appear as if "Tom" would have worked all time at "Mario's Apples".

If I had this nice ID-variable, I were able to include it in my by-statement and I was fine.

 

So if someone could please tell me how to create this very ID (because in general it would help me to know how to do it) or otherwise could provide me with a means of how to solve my problem, for the means of which I have thought of appears as rather clumsy to me ("there for sure is a much more sophisticated solution"), I would be very glad.

 

Yours sincerely,
Sinistrum

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Post test data in the form of a datastep in the body of the post, I don't download files, or type in test data.  So this is just a rough outline.  You should just be able to increment at each new manager:

data want;
  set have;
  by company manager notsorted;
  retain id;
  if first.company then id=0;
  if first.manager then id=sum(id,1);
run;

 

View solution in original post

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Post test data in the form of a datastep in the body of the post, I don't download files, or type in test data.  So this is just a rough outline.  You should just be able to increment at each new manager:

data want;
  set have;
  by company manager notsorted;
  retain id;
  if first.company then id=0;
  if first.manager then id=sum(id,1);
run;

 

Sinistrum
Quartz | Level 8

Thank you very much indeed -

it once again is truly breathtaking, how fast I receive responses.

 

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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
  • 2 replies
  • 679 views
  • 1 like
  • 2 in conversation