Data Transformation

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Data Transformation

Deepanshu Bhalla
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Data Transformation

Marta Garcia-Granero
HI DB

1) Untested:

SELECT IF ANY(Age,1,2,3,4).

2) Your question is not clear. Why:

AGGREGATE
  /OUTFILE=* MODE=ADDVARIABLES
  /BREAK=q1 TOJ GENDER AGE
  /v18_mean=MEAN(v18) 
  /v19_mean=MEAN(v19).

is not OK?

Marta

El 24/02/2012 17:24, deepanshu bhalla escribió:
Hi Team,

I have 2 questions :

(1) How can we compress the below select if command ?
Select if age = 1 or age = 2 or age =3 or age =4.
execute.
I mean can we do the transformation like this ( or some other cool way to do this problem ):
Define age () 1 2 3 4.
!ENDDEFINE.
Select if age.
Execute.

(2) Aggregate command :
Define Demogs () Age !ENDDEFINE.

AGGREGATE
  /OUTFILE=* MODE=ADDVARIABLES
  /BREAK=q1 Demogs
  /v18_mean=MEAN(v18) 
  /v19_mean=MEAN(v19).

How can we use the above aggregate function for multiple demogs such as TOJ,GENDER,AGE?

Define Demogs() TOJ GENDER AGE !ENDDEFINE.

I want syntax that would first go to first demog i.e TOJ and once aggregate is completed it go to second demog and goes on...( NOTE : I want data breaked by only one demog  at one time )

Thanks in advance !













Reply | Threaded
Open this post in threaded view
|

Re: Data Transformation

David Marso
Administrator
In reply to this post by Deepanshu Bhalla
1.  See ANY function in the FM.  Marta has provided an example below and there are countless examples in the archives of this group.  And it is *NOT* limited to simple comparisons of values.
eg  
IF ANY(1,(x eq 2),(y-x GT 3), blah blah blah) Shazam=20175.

2.  First off, in my not so humble opinion it is *usually* silly to use DEFINE () blah blah !ENDDEFINE.
Learn to pass parameters to macros rather than littering your code with the above form of abomination.

DEFINE Aggrevate (Demogs !CMDEND ).
!DO !D !IN (!Demogs)
AGGREGATE OUTFILE * / MODE ADDVARIABLES / BREAK !D /blah blah blah........
!DOEND
!ENDDEFINE.

HTH, David
--


deepanshu bhalla wrote
Hi Team,

I have 2 questions :

(1) How can we compress the below select if command ?
Select if age = 1 or age = 2 or age =3 or age =4.

execute.
I mean can we do the transformation like this ( or some other cool way to do this problem ):

Define age () 1 2 3 4.
!ENDDEFINE.
Select if age.
Execute.

(2) Aggregate command :
Define Demogs () Age !ENDDEFINE.

AGGREGATE
  /OUTFILE=* MODE=ADDVARIABLES
  /BREAK=q1 Demogs
  /v18_mean=MEAN(v18) 
  /v19_mean=MEAN(v19).

How can we use the above aggregate function for multiple demogs such as TOJ,GENDER,AGE?

Define Demogs() TOJ GENDER AGE !ENDDEFINE.

I want syntax that would first go to first demog i.e TOJ and once aggregate is completed it go to second demog and goes on...( NOTE : I want data breaked by only one demog  at one time )

Thanks in advance !
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"