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
Are you programming in IML or BASE? If IML you may want to repost this in the IML forum.
I do not know how to program in IML.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.