hello all,
for the table have like below,
Type | year | WC01201 |
28221H | 1990 | 9598 |
28221H | 1991 | 4651 |
28221H | 1992 | 6174 |
28221H | 1993 | 16307 |
28221H | 1994 | 12497 |
28221H | 1995 | 9063 |
28221H | 1996 | 8067 |
28221H | 1997 | 19637 |
28221H | 1998 | 2445 |
28221H | 1999 | 5101 |
28221H | 2000 | 2222 |
28221H | 2001 | . |
28221H | 2002 | . |
28221H | 2003 | . |
28221H | 2004 | . |
28221H | 2005 | . |
28221H | 2006 | . |
28221H | 2007 | . |
28221H | 2008 | . |
28221H | 2009 | . |
28221H | 2010 | . |
28221H | 2011 | . |
28221H | 2012 | . |
8912GT | . | . |
307059 | . | . |
413321 | . | . |
For each ID in the Type variable (eg., '8912GT'), if the value of 'Year' is '.' then I expect to write the value from '1990' to '2012' into it, and expect to get the result like below,
Type | year | WC01201 |
28221H | 1990 | 9598 |
28221H | 1991 | 4651 |
28221H | 1992 | 6174 |
28221H | 1993 | 16307 |
28221H | 1994 | 12497 |
28221H | 1995 | 9063 |
28221H | 1996 | 8067 |
28221H | 1997 | 19637 |
28221H | 1998 | 2445 |
28221H | 1999 | 5101 |
28221H | 2000 | 2222 |
28221H | 2001 | . |
28221H | 2002 | . |
28221H | 2003 | . |
28221H | 2004 | . |
28221H | 2005 | . |
28221H | 2006 | . |
28221H | 2007 | . |
28221H | 2008 | . |
28221H | 2009 | . |
28221H | 2010 | . |
28221H | 2011 | . |
28221H | 2012 | . |
8912GT | 1990 | . |
8912GT | 1991 | . |
8912GT | 1992 | . |
8912GT | 1993 | . |
8912GT | 1994 | . |
8912GT | 1995 | . |
8912GT | 1996 | . |
8912GT | 1997 | . |
8912GT | 1998 | . |
8912GT | 1999 | . |
8912GT | 2000 | . |
8912GT | 2001 | . |
8912GT | 2002 | . |
8912GT | 2003 | . |
8912GT | 2004 | . |
8912GT | 2005 | . |
8912GT | 2006 | . |
8912GT | 2007 | . |
8912GT | 2008 | . |
8912GT | 2009 | . |
8912GT | 2010 | . |
8912GT | 2011 | . |
8912GT | 2012 | . |
307059 | 1990 | . |
307059 | 1991 | . |
307059 | 1992 | . |
307059 | 1993 | . |
307059 | 1994 | . |
307059 | 1995 | . |
307059 | 1996 | . |
307059 | 1997 | . |
307059 | 1998 | . |
307059 | 1999 | . |
307059 | 2000 | . |
307059 | 2001 | . |
307059 | 2002 | . |
307059 | 2003 | . |
307059 | 2004 | . |
307059 | 2005 | . |
307059 | 2006 | . |
307059 | 2007 | . |
307059 | 2008 | . |
307059 | 2009 | . |
307059 | 2010 | . |
307059 | 2011 | . |
307059 | 2012 | . |
413321 | 1990 | . |
413321 | 1991 | . |
413321 | 1992 | . |
413321 | 1993 | . |
413321 | 1994 | . |
413321 | 1995 | . |
413321 | 1996 | . |
413321 | 1997 | . |
413321 | 1998 | . |
413321 | 1999 | . |
413321 | 2000 | . |
413321 | 2001 | . |
413321 | 2002 | . |
413321 | 2003 | . |
413321 | 2004 | . |
413321 | 2005 | . |
413321 | 2006 | . |
413321 | 2007 | . |
413321 | 2008 | . |
413321 | 2009 | . |
413321 | 2010 | . |
413321 | 2011 | . |
413321 | 2012 | . |
I have no idea about it, could you please give me some suggestions about it?
data Have;
INFILE CARDS DSD DLM=',';
input
Type :$1000.
Yaer :4.
WC01201 :10.;
cards;
28221H,1990,9598
28221H,1991,4651
28221H,1992,6174
28221H,1993,16307
28221H,1994,12497
28221H,1995,9063
28221H,1996,8067
28221H,1997,19637
28221H,1998,2445
28221H,1999,5101
28221H,2000,2222
28221H,2001,
28221H,2002,
28221H,2003,
28221H,2004,
28221H,2005,
28221H,2006,
28221H,2007,
28221H,2008,
28221H,2009,
28221H,2010,
28221H,2011,
28221H,2012,
8912GT,,
307059,,
413321,,
;
RUN;
thanks in advance.
data Have;
INFILE CARDS DSD DLM=',';
input
Type :$1000.
Year :4.
WC01201 :10.;
cards;
28221H,1990,9598
28221H,1991,4651
28221H,1992,6174
28221H,1993,16307
28221H,1994,12497
28221H,1995,9063
28221H,1996,8067
28221H,1997,19637
28221H,1998,2445
28221H,1999,5101
28221H,2000,2222
28221H,2001,
28221H,2002,
28221H,2003,
28221H,2004,
28221H,2005,
28221H,2006,
28221H,2007,
28221H,2008,
28221H,2009,
28221H,2010,
28221H,2011,
28221H,2012,
8912GT,,
307059,,
413321,,
;
RUN;
data want;
set have;
if year=. then do year=1990 to 2012;
output;
end;
else output;
run;
data Have;
INFILE CARDS DSD DLM=',';
input
Type :$1000.
Year :4.
WC01201 :10.;
cards;
28221H,1990,9598
28221H,1991,4651
28221H,1992,6174
28221H,1993,16307
28221H,1994,12497
28221H,1995,9063
28221H,1996,8067
28221H,1997,19637
28221H,1998,2445
28221H,1999,5101
28221H,2000,2222
28221H,2001,
28221H,2002,
28221H,2003,
28221H,2004,
28221H,2005,
28221H,2006,
28221H,2007,
28221H,2008,
28221H,2009,
28221H,2010,
28221H,2011,
28221H,2012,
8912GT,,
307059,,
413321,,
;
RUN;
data want;
set have;
if year=. then do year=1990 to 2012;
output;
end;
else output;
run;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.