LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (March 2009, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Thu, 5 Mar 2009 09:21:49 -0500
Reply-To:   Ian Whitlock <iw1sas@GMAIL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Ian Whitlock <iw1sas@GMAIL.COM>
Subject:   Re: I wanrt to use all variables in macro for the same process but something is wrong !!
Comments:   cc: "vrajeshrawal@gmail.com" <vrajeshrawal@gmail.com>
Content-Type:   text/plain; charset=ISO-8859-1

Vrajeshrawal,

First let's look at SAS. Suppose you have a variable X and want to insert a "/".

x = cats(substr(x,1,1),"/",substr(x,2)) ;

If there are some value of X that should not get the "/" then you might want

if x in ( "AA" ... "CC" ) then x = cats(substr(x,1,1),"/",substr(x,2)) ;

Now you want to do it for a lot of variables.

data wanted ; length .... $ 3 ; array chars (*) ..... ; set <something> ; do i = 1 to dim ( chars ) ; chars[i] = cats(substr(chars[i],1,1),"/",substr(chars[i],2)) ; end ; run ;

So now we are ready to write code.

Proc Sql Noprint ; Select Distinct name into : V_names separated by ' ' from dictionary.columns where libname = "DAMODAR" and memname = "GG_GENOTYPE_PHENOTYPE_2" ; Quit ;

data wanted ( drop = i ) ; length &v_names $ 3 ; array chars (*) &v_names ; set <something> ; do i = 1 to dim ( chars ) ; chars[i] = cats(substr(chars[i],1,1),"/",substr(chars[i],2)) ; end ; run ;

It is far from clear why you might need a slash so if you explained what you are doing you might get better help. It is alway best to give example data, your imediate problem, and the reason you want to solve the immediate problem. The more information you can give to SAS-L, the more you will get quality information from it.

Ian Whitlock ===============

Date: Thu, 5 Mar 2009 03:33:51 -0800 From: "vrajeshrawal@gmail.com" <vrajeshrawal@GMAIL.COM> Subject: I wanrt to use all variables in macro for the same process but something is wrong !!

I am getting error as list of variables is seprated just by space and going much beyond the limits.....

%macro variable(V_name);

Proc Contents data=DAMODAR.GG_GENOTYPE_PHENOTYPE_2 out = Te_c (keep = name ) ; Run;

Proc Sql Noprint ; Select Distinct name into : V_name separated by ' ' from te_c ; Quit ;

%mend variable;

%macro snps (V_name);

Data DAMODAR.GG_GENOTYPE_PHENOTYPE_3; length _ALL_ $3; set DAMODAR.GG_GENOTYPE_PHENOTYPE_2 ;

if &V_name= "AA" then do; &V_name = tranwrd(&V_name,"AA","A/A");end; else if &V_name= "AT" then do; &V_name = tranwrd(&V_name,"AT","A/ T");end; else if &V_name= "AG" then do; &V_name = tranwrd(&V_name,"AG","A/ G");end; else if &V_name= "AC" then do; &V_name = tranwrd(&V_name,"AC","A/ C");end;

else if &V_name= "TA" then do; &V_name = tranwrd(&V_name,"TA","T/ A");end; else if &V_name= "TT" then do; &V_name = tranwrd(&V_name,"TT","T/ T");end; else if &V_name= "TG" then do; &V_name = tranwrd(&V_name,"TG","T/ G");end; else if &V_name= "TC" then do; &V_name = tranwrd(&V_name,"TC","T/ C");end;

else if &V_name= "GA" then do; &V_name = tranwrd(&V_name,"GA","G/ A");end; else if &V_name= "GT" then do; &V_name = tranwrd(&V_name,"GT","G/ T");end; else if &V_name= "GG" then do; &V_name = tranwrd(&V_name,"GG","G/ G");end; else if &V_name= "GC" then do; &V_name = tranwrd(&V_name,"GC","G/ C");end;

else if &V_name= "CA" then do; &V_name = tranwrd(&V_name,"CA","C/ A");end; else if &V_name= "CT" then do; &V_name = tranwrd(&V_name,"CT","C/ T");end; else if &V_name= "CG" then do; &V_name = tranwrd(&V_name,"CG","C/ G");end; else if &V_name= "CC" then do; &V_name = tranwrd(&V_name,"CC","C/ C");end;

run;

%mend SNPS ;

%variable (V_name);


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