Prev: how to get the code lines into the program editor window?
Next: how to use macro variable for file name
From: Amar Mundankar on 16 Apr 2010 10:23 Hi all, I have 3 input datasets. data ONE; a_access = 'M'; Access = 'K'; z = 2; y = 6; b_dio_access ='C'; run; data two; a_access = 'X'; b_dio_access = 'A'; access = 'K'; z = 62; y = 6; run; data access_code; input Code $ Value; cards; A 1 C 2 K 3 M 4 X 5 ; =========================== Table Want: a_access a_access_flag access access_flag b_dio_access b_dio_access_flag y z X +1 K 0 A -1 6 62 ==================================== I want to compare dataset ONE and TWO based on the column names which contains word 'access'. So in the comparison only access,a_access,b_dio_access columns will be considered. The value access,a_access,b_dio_access columns from table TWO will be compared with the values for respective columns from Table ONE. While comparing the two values i have to consider values of "Value" column from the Access_Code table. e.g. a_access column from table Two has value 'X'and 'M' in table One. So I will subtract 5 from 4 (because X=5 and M=4 in access_code column). Answer is positive so flag value will be +1. I will create a column as a_access_flag and will put the value +1 in it. ====================================== Till now I am only able to find out the column name which contains word 'access'. And I am able to count the number of columns by writing a macro as %wordcnt. Plase help me as I need it very urgently. This is what, I have done so far. proc sql; select distinct(name) into :col_name separated by ' ' from dictionary.columns where upcase(libname) = 'WORK' and upcase(memname) = 'TWO' and upcase(name) like '%ACCESS%'; quit; %PUT _USER_; %GLOBAL COUNT; %macro wordcnt (string); %let count = 1; %do %until (%qscan (&string, &count, %str ( )) = ); %let count = %eval (&count + 1); %end; %eval (&count - 1) %mend wordcnt; %LET X = %WORDCNT(&COL_NAME); %PUT &X ; ======================== Thanks in Advance. Regards, Amar Mundankar. |