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

I have a panel data with 1002 observations. N=334, T=3. My goal is to create 2 columns representing N and the year T. For example, the first 334 observations will have ID from 1 to 334 and a fixed value of T=1. The next set will have observations from 335 to 668 and T=2. I tried this piece of code but it did not work. 

 

DATA WAGE;
SET WAGE(first_obs = 2)(obs = 335);
retain Person_ID = 1;
retain Year_ID = 1;
Person_ID + 1;
RUN;

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

Could be as basic as:

 

data want;
do T = 1 to 3;
    do ID = 1 to 334;
        set WAGE;
        output;
        end;
    end;
run;
PG

View solution in original post

2 REPLIES 2
PGStats
Opal | Level 21

Could be as basic as:

 

data want;
do T = 1 to 3;
    do ID = 1 to 334;
        set WAGE;
        output;
        end;
    end;
run;
PG
ballardw
Super User

Perhaps:

 

data want;
   set wage;
   id=_n_;
   t = floor((_n_-1)/334)+1;
run;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 2 replies
  • 835 views
  • 1 like
  • 3 in conversation