DATA Step, Macro, Functions and more

creating a vector

Reply
Frequent Contributor
Posts: 102

creating a vector

Hello,
Below is a small sample of a large data set.

Firmid year segmentID segmentsales siccode
1001 1999 1 20 4100
1001 1999 2 10 4200
1001 2000 1 15 4100
1001 2000 2 12 4200
1001 2000 3 13 5100
1002 1999 1 20 4100
1002 1999 2 13 9100
1002 2001 1 20 2867
1002 2001 2 13 3200
1002 2000 3 20 7100

1. First, I can compute how many unique siccode my data has, in this small example above, I have 7 unique siccode
2. my vector will have 7 elements, each element correspond to the segmentsales, for each firm-year, there are non-zero segmentsales and zero segmentsales  (when the firm does not have such a segment), e.g. firmid=1001, year=1999, my vector =[20,10,0,0,0,0,0], firmid=1001, year=2000, my vector =[15,12,13,0,0,0]

How should I program this?

Thanks!

Lan

Super User
Posts: 17,868

Re: creating a vector

Are you programming in IML or BASE? If IML you may want to repost this in the IML forum.

Frequent Contributor
Posts: 102

Re: creating a vector

I do not know how to program in IML.

Ask a Question
Discussion stats
  • 2 replies
  • 150 views
  • 0 likes
  • 2 in conversation