```Date: Mon, 13 Jan 2003 09:04:51 -0800 Reply-To: "Huang, Ya" Sender: "SAS(r) Discussion" From: "Huang, Ya" Subject: Re: Identify the Interge variable Comments: To: Jerry Content-Type: text/plain; charset="iso-8859-1" Jerry, To test whether a number is integer, you can use mod function. If mod(a,1)=0, a is a integer, otherwise, it is not. Now this is for each individual value of variable a, your problem is to find if all the value of a is integer, my algorithms is to find the max of all the remainder of a, and the min of all the remainder of a, if they all equals to 0, then the variable a is an integer, this can be done by one simple proc sql step. The data step in the following code, is just to transpose the data so that it match your sample's layout: data xx; input a b; cards; 1 1.3 4 7.9 0 9.8 4 9.1 ; options nocenter; proc sql; create table intnum as select case when max(mod(a,1))= 0 and min(mod(a,1))= 0 then 'yes' else 'no' end as aflag, case when max(mod(b,1))= 0 and min(mod(b,1))= 0 then 'yes' else 'no' end as bflag, case when calculated aflag='yes' then count(distinct a) else . end as anum, case when calculated bflag='yes' then count(distinct b) else . end as bnum from xx ; proc print; run; data intnum; set intnum; varname='a'; integer=aflag; num=anum; output; varname='b'; integer=bflag; num=bnum; output; keep varname integer num; run; proc print; run; -------------------- Obs aflag bflag anum bnum 1 yes no 3 . Obs varname integer num 1 a yes 3 2 b no . HTH Ya Huang -----Original Message----- From: Jerry [mailto:yhow29@MSN.COM] Sent: Monday, January 13, 2003 8:12 AM To: SAS-L@LISTSERV.UGA.EDU Subject: Identify the Interge variable Dear All: I got a problem to create a macro. I need a macro to identify interge variables from a data set. for example: a b 1 1.3 4 7.9 0 9.8 4 9.1 ; For each interge variable I also need to know how many unique value the variable has. Finally, I want to create a dataset like: VarName Interge Num a yes 3 b no . ; Thanks a lot. Jerry ```

Back to: Top of message | Previous page | Main SAS-L page