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

hello all,

 

for the table have like below,

TypeyearWC01201
28221H19909598
28221H19914651
28221H19926174
28221H199316307
28221H199412497
28221H19959063
28221H19968067
28221H199719637
28221H19982445
28221H19995101
28221H20002222
28221H2001.
28221H2002.
28221H2003.
28221H2004.
28221H2005.
28221H2006.
28221H2007.
28221H2008.
28221H2009.
28221H2010.
28221H2011.
28221H2012.
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,

 

TypeyearWC01201
28221H19909598
28221H19914651
28221H19926174
28221H199316307
28221H199412497
28221H19959063
28221H19968067
28221H199719637
28221H19982445
28221H19995101
28221H20002222
28221H2001.
28221H2002.
28221H2003.
28221H2004.
28221H2005.
28221H2006.
28221H2007.
28221H2008.
28221H2009.
28221H2010.
28221H2011.
28221H2012.
8912GT1990.
8912GT1991.
8912GT1992.
8912GT1993.
8912GT1994.
8912GT1995.
8912GT1996.
8912GT1997.
8912GT1998.
8912GT1999.
8912GT2000.
8912GT2001.
8912GT2002.
8912GT2003.
8912GT2004.
8912GT2005.
8912GT2006.
8912GT2007.
8912GT2008.
8912GT2009.
8912GT2010.
8912GT2011.
8912GT2012.
3070591990.
3070591991.
3070591992.
3070591993.
3070591994.
3070591995.
3070591996.
3070591997.
3070591998.
3070591999.
3070592000.
3070592001.
3070592002.
3070592003.
3070592004.
3070592005.
3070592006.
3070592007.
3070592008.
3070592009.
3070592010.
3070592011.
3070592012.
4133211990.
4133211991.
4133211992.
4133211993.
4133211994.
4133211995.
4133211996.
4133211997.
4133211998.
4133211999.
4133212000.
4133212001.
4133212002.
4133212003.
4133212004.
4133212005.
4133212006.
4133212007.
4133212008.
4133212009.
4133212010.
4133212011.
4133212012.

 

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.

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20
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;

View solution in original post

1 REPLY 1
novinosrin
Tourmaline | Level 20
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;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 1 reply
  • 242 views
  • 1 like
  • 2 in conversation