f



i have a BIG database, the variable names are in the left column Now i would like to crate one new variable using information from the variable names

i have a BIG database,
the variable names are in the left column
Now i would like to crate one new variable:

FOR arararara>10 AND arararara<83 
EX.   If arararara=73 that variable should be the sum of SINSJO73 and SINSJO73M

For arararara 83-99 or arararara 00-09 there are four variables to calculate

EX. If arararara=94 that variable should be the sum of
SINSJO94
SOCB94
SINSJO94M
SOCB94M

Please!



arararara	73	94
SINSJO73	35664	28931
SINSJO74	41259	32379
SINSJO75	51368	37279
SINSJO76	59752	41826
SINSJO77	66719	47526
SINSJO78	62300	52600
SINSJO79	64400	57500
SINSJO80	67600	60100
SINSJO81	72900	62500
SINSJO82	78900	75500
SINSJO83	77700	85600
SOCB83	0	0
SINSJO84	90600	90100
SOCB84	1400	0
SINSJO85	94200	95600
SOCB85	0	0
SINSJO86	105100	99300
SOCB86	0	0
SINSJO87	114800	114600
SOCB87	0	0
SINSJO88	123500	122400
SOCB88	0	0
SINSJO89	148300	124000
SOCB89	0	0
SINSJO90	170400	139700
SOCB90	0	0
SINSJO91	163500	147700
SOCB91	0	0
SINSJO92	165900	160000
SOCB92	0	0
SINSJO93	182500	163100
SOCB93	0	0
SINSJO94	198939	171201
SOCB94	0	0
SINSJO95	221963	174798
SOCB95	0	0
SINSJO96	222675	170244
SOCB96	0	0
SINSJO97	231926	160094
SOCB97	0	0
SINSJO98	247964	176483
SOCB98	0	0
SINSJO99	257403	188740
SOCB99	0	0
SINSJO00	269929	181875
SOCB00	0	0
SINSJO01	276377	199816
SOCB01	0	0
SINSJO02	313054	217765
SOCB02	0	0
SINSJO03	329165	178910
SOCB03	0	0
SINSJO04	357489	153011
SOCB04	0	0
SINSJO05	357272	174591
SOCB05	0	0
SINSJO06	376580	
SOCB06	0	
SINSJO07	431546	
SOCB07	0	
SINSJO08	302793	
SOCB08	0	
SINSJO09	309948	
SOCB09	0	
SINSJO73M	0	286
SINSJO74M	4859	0
SINSJO75M	5294	11960
SINSJO76M	347	11841
SINSJO77M	100	14050
SINSJO78M	900	15100
SINSJO79M	900	15800
SINSJO80M	5000	17300
SINSJO81M	800	22700
SINSJO82M	1200	21400
SINSJO83M	1200	19800
SOCB83M	0	0
SINSJO84M	29900	22700
SOCB84M	0	0
SINSJO85M	46500	21100
SOCB85M	0	0
SINSJO86M	49500	19800
SOCB86M	0	0
SINSJO87M	74900	20200
SOCB87M	0	0
SINSJO88M	105600	19400
SOCB88M	0	0
SINSJO89M	94500	102600
SOCB89M	0	0
SINSJO90M	80800	129000
SOCB90M	0	0
SINSJO91M	59500	138200
SOCB91M	0	0
SINSJO92M	46700	155100
SOCB92M	0	0
SINSJO93M	11400	154500
SOCB93M	0	0
SINSJO94M	40894	170603
SOCB94M	0	0
SINSJO95M	132765	169020
SOCB95M	0	0
SINSJO96M	140799	174138
SOCB96M	0	0
SINSJO97M	131689	178531
SOCB97M	0	0
SINSJO98M	171479	188557
SOCB98M	0	0
SINSJO99M	171884	196287
SOCB99M	0	0
SINSJO00M	231308	211513
SOCB00M	0	0
SINSJO01M	175649	216354
SOCB01M	0	0
SINSJO02M	198403	235559
SOCB02M	0	0
SINSJO03M	205704	240791
SOCB03M	0	0
SINSJO04M	213714	237289
SOCB04M	0	0
SINSJO05M	219601	228099
SOCB05M	0	0
SINSJO06M	216834	268877
SOCB06M	0	0
SINSJO07M	235902	255788
SOCB07M	0	0
SINSJO08M	243001	141751
SOCB08M	0	0
SINSJO09M	213451	219578
SOCB09M	0	0
NEW_VAR	        35664	341804

0
lars9961 (5)
9/18/2012 1:23:45 PM
comp.soft-sys.sas 142827 articles. 4 followers. Post Follow

3 Replies
1363 Views

Similar Articles

[PageSpeed] 15

On Tuesday, September 18, 2012 7:23:45 AM UTC-6, LL wrote:
> i have a BIG database,
> 
> the variable names are in the left column
> 
> Now i would like to crate one new variable:
> 
> 
> 
> FOR arararara>10 AND arararara<83 
> 
> EX.   If arararara=73 that variable should be the sum of SINSJO73 and SINSJO73M
> 
> 
> 
> For arararara 83-99 or arararara 00-09 there are four variables to calculate
> 
> 
> 
> EX. If arararara=94 that variable should be the sum of
> 
> SINSJO94
> 
> SOCB94
> 
> SINSJO94M
> 
> SOCB94M
> 
> 
> 
> Please!
> 
> 
> 
> 
> 
> 
> 
> arararara	73	94
> 
> SINSJO73	35664	28931
> 
> SINSJO74	41259	32379
> 
> SINSJO75	51368	37279
> 
> SINSJO76	59752	41826
> 
> SINSJO77	66719	47526
> 
> SINSJO78	62300	52600
> 
> SINSJO79	64400	57500
> 
> SINSJO80	67600	60100
> 
> SINSJO81	72900	62500
> 
> SINSJO82	78900	75500
> 
> SINSJO83	77700	85600
> 
> SOCB83	0	0
> 
> SINSJO84	90600	90100
> 
> SOCB84	1400	0
> 
> SINSJO85	94200	95600
> 
> SOCB85	0	0
> 
> SINSJO86	105100	99300
> 
> SOCB86	0	0
> 
> SINSJO87	114800	114600
> 
> SOCB87	0	0
> 
> SINSJO88	123500	122400
> 
> SOCB88	0	0
> 
> SINSJO89	148300	124000
> 
> SOCB89	0	0
> 
> SINSJO90	170400	139700
> 
> SOCB90	0	0
> 
> SINSJO91	163500	147700
> 
> SOCB91	0	0
> 
> SINSJO92	165900	160000
> 
> SOCB92	0	0
> 
> SINSJO93	182500	163100
> 
> SOCB93	0	0
> 
> SINSJO94	198939	171201
> 
> SOCB94	0	0
> 
> SINSJO95	221963	174798
> 
> SOCB95	0	0
> 
> SINSJO96	222675	170244
> 
> SOCB96	0	0
> 
> SINSJO97	231926	160094
> 
> SOCB97	0	0
> 
> SINSJO98	247964	176483
> 
> SOCB98	0	0
> 
> SINSJO99	257403	188740
> 
> SOCB99	0	0
> 
> SINSJO00	269929	181875
> 
> SOCB00	0	0
> 
> SINSJO01	276377	199816
> 
> SOCB01	0	0
> 
> SINSJO02	313054	217765
> 
> SOCB02	0	0
> 
> SINSJO03	329165	178910
> 
> SOCB03	0	0
> 
> SINSJO04	357489	153011
> 
> SOCB04	0	0
> 
> SINSJO05	357272	174591
> 
> SOCB05	0	0
> 
> SINSJO06	376580	
> 
> SOCB06	0	
> 
> SINSJO07	431546	
> 
> SOCB07	0	
> 
> SINSJO08	302793	
> 
> SOCB08	0	
> 
> SINSJO09	309948	
> 
> SOCB09	0	
> 
> SINSJO73M	0	286
> 
> SINSJO74M	4859	0
> 
> SINSJO75M	5294	11960
> 
> SINSJO76M	347	11841
> 
> SINSJO77M	100	14050
> 
> SINSJO78M	900	15100
> 
> SINSJO79M	900	15800
> 
> SINSJO80M	5000	17300
> 
> SINSJO81M	800	22700
> 
> SINSJO82M	1200	21400
> 
> SINSJO83M	1200	19800
> 
> SOCB83M	0	0
> 
> SINSJO84M	29900	22700
> 
> SOCB84M	0	0
> 
> SINSJO85M	46500	21100
> 
> SOCB85M	0	0
> 
> SINSJO86M	49500	19800
> 
> SOCB86M	0	0
> 
> SINSJO87M	74900	20200
> 
> SOCB87M	0	0
> 
> SINSJO88M	105600	19400
> 
> SOCB88M	0	0
> 
> SINSJO89M	94500	102600
> 
> SOCB89M	0	0
> 
> SINSJO90M	80800	129000
> 
> SOCB90M	0	0
> 
> SINSJO91M	59500	138200
> 
> SOCB91M	0	0
> 
> SINSJO92M	46700	155100
> 
> SOCB92M	0	0
> 
> SINSJO93M	11400	154500
> 
> SOCB93M	0	0
> 
> SINSJO94M	40894	170603
> 
> SOCB94M	0	0
> 
> SINSJO95M	132765	169020
> 
> SOCB95M	0	0
> 
> SINSJO96M	140799	174138
> 
> SOCB96M	0	0
> 
> SINSJO97M	131689	178531
> 
> SOCB97M	0	0
> 
> SINSJO98M	171479	188557
> 
> SOCB98M	0	0
> 
> SINSJO99M	171884	196287
> 
> SOCB99M	0	0
> 
> SINSJO00M	231308	211513
> 
> SOCB00M	0	0
> 
> SINSJO01M	175649	216354
> 
> SOCB01M	0	0
> 
> SINSJO02M	198403	235559
> 
> SOCB02M	0	0
> 
> SINSJO03M	205704	240791
> 
> SOCB03M	0	0
> 
> SINSJO04M	213714	237289
> 
> SOCB04M	0	0
> 
> SINSJO05M	219601	228099
> 
> SOCB05M	0	0
> 
> SINSJO06M	216834	268877
> 
> SOCB06M	0	0
> 
> SINSJO07M	235902	255788
> 
> SOCB07M	0	0
> 
> SINSJO08M	243001	141751
> 
> SOCB08M	0	0
> 
> SINSJO09M	213451	219578
> 
> SOCB09M	0	0
> 
> NEW_VAR	        35664	341804

I'm not 100% sure what you're trying to do, but some well defined arrays may help out along with the vname function. Is your data actually structured like above or is that for simplication of viewing?
0
fkhurshed1 (386)
9/18/2012 3:17:39 PM
I have a databes with more then 30000000 observations, each observation has all these variables that are in the left column .
Only two observations are presented here;
I would like to get  a script/array that  creates the newwar which is the sum all the values of all variables with 73 in their variable name
0
lars9961 (5)
9/18/2012 6:07:59 PM
On Tuesday, September 18, 2012 12:07:59 PM UTC-6, LL wrote:
> I have a databes with more then 30000000 observations, each observation h=
as all these variables that are in the left column .
>=20
> Only two observations are presented here;
>=20
> I would like to get  a script/array that  creates the newwar which is the=
 sum all the values of all variables with 73 in their variable name

If you only have a few criteria type them out. If its more complicated then=
 you can loop over all variables (highly inefficient). Not sure if your nam=
ing convention might lend itself to using the : operator, ie if you had hei=
ght73_1 and height73_2 you could sum them using sum(of height73:);

data want;
set have;
array num(*) _numeric_;
newvar=3D0;
do i=3D1 to dim(num);
if find('73', vname(num(i))>0 then newvar+num(i);
end;
run;
0
fkhurshed1 (386)
9/19/2012 5:15:11 PM
Reply: