From: Tom Abernathy on 15 Apr 2010 16:19 If you just want to type in the list then you could us a simple data step to generate the resulting strings and copy and paste the result back into the log. data _null_; length country $16 stat $16 varname $32 ; do country = 'japan','usa'; do stat = 'population','area'; varname = catx(country,stat); put varname; end; end; run; On Apr 14, 6:11 am, "Jinto83" <jint...(a)sina.com> wrote: > Hi, I want to define a bunch of variables: > > japanpopulation=something someting > japanarea=something someting > usapopulation=something someting > usaarea=something someting > > How do I loop inside two loops: > 1.[japan,usa] > 2.[population,area] > And define new variable names based on the cartesian product of the two arrays? > > --- news://freenews.netfront.net/ - complaints: n...(a)netfront.net ---
From: Jinto83 on 16 Apr 2010 19:48 Thank you, That is almost what I wanted. Unfortunately it generates the list in rows; whereas I want the list in columns I want to initialize 4 variables with value one. So I have four columns of variables, all of them equal to one. Can SAS be able to do that without using the manual copying pasting from log? "Tom Abernathy" <tom.abernathy(a)gmail.com> ???? news:e8f8e11f-66a6-4047-8fe2-8d348835a204(a)i25g2000yqm.googlegroups.com... If you just want to type in the list then you could us a simple data step to generate the resulting strings and copy and paste the result back into the log. data _null_; length country $16 stat $16 varname $32 ; do country = 'japan','usa'; do stat = 'population','area'; varname = catx(country,stat); put varname; end; end; run; On Apr 14, 6:11 am, "Jinto83" <jint...(a)sina.com> wrote: > Hi, I want to define a bunch of variables: > > japanpopulation=something someting > japanarea=something someting > usapopulation=something someting > usaarea=something someting > > How do I loop inside two loops: > 1.[japan,usa] > 2.[population,area] > And define new variable names based on the cartesian product of the two arrays? > > --- news://freenews.netfront.net/ - complaints: n...(a)netfront.net --- --- news://freenews.netfront.net/ - complaints: news(a)netfront.net ---
From: Tom Abernathy on 16 Apr 2010 21:18
Generate some code into a macro and then use in your intended data step. data _null_; length code $1000; length country $16 stat $16 varname $32 ; do country = 'japan','usa'; do stat = 'population','area'; varname = catx(country,stat); code = catx(code,varname || '=1;'); end; end; call symputx('code',code); run; data real ; &out; ...... run; On Apr 16, 7:48 pm, "Jinto83" <jint...(a)sina.com> wrote: > Thank you, That is almost what I wanted. > Unfortunately it generates the list in rows; whereas I want the list in columns > I want to initialize 4 variables with value one. So I have four columns of variables, all of them equal to one. > Can SAS be able to do that without using the manual copying pasting from log? > > "Tom Abernathy" <tom.aberna...(a)gmail.com> ????news:e8f8e11f-66a6-4047-8fe2-8d348835a204(a)i25g2000yqm.googlegroups.com... > If you just want to type in the list then you could us a simple data > step to generate the resulting strings and copy and paste the result > back into the log. > > data _null_; > length country $16 stat $16 varname $32 ; > do country = 'japan','usa'; > do stat = 'population','area'; > varname = catx(country,stat); > put varname; > end; > end; > run; > > On Apr 14, 6:11 am, "Jinto83" <jint...(a)sina.com> wrote: > > > Hi, I want to define a bunch of variables: > > > japanpopulation=something someting > > japanarea=something someting > > usapopulation=something someting > > usaarea=something someting > > > How do I loop inside two loops: > > 1.[japan,usa] > > 2.[population,area] > > And define new variable names based on the cartesian product of the two arrays? > > > --- news://freenews.netfront.net/ - complaints: n...(a)netfront.net --- > > --- news://freenews.netfront.net/ - complaints: n...(a)netfront.net --- |