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;
Could be as basic as:
data want;
do T = 1 to 3;
do ID = 1 to 334;
set WAGE;
output;
end;
end;
run;
Could be as basic as:
data want;
do T = 1 to 3;
do ID = 1 to 334;
set WAGE;
output;
end;
end;
run;
Perhaps:
data want; set wage; id=_n_; t = floor((_n_-1)/334)+1; run;
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.
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.