I am new to Stata, I have a small doubt, Any Help would be greatly appreciated.
TABLE1(.dta)
| Column1 | Column2 | Column3 | Column4 | 
| ZA112234 | CA52167 | PK09146 | VF90103 | 
| ZA114234 | CA52564 | K091743 | VF90115 | 
| ZA115432 | CA52734 | JI090803 | CA52012 | 
| ZA116444 | CA52923 | KL02134 | CA52173 | 
| ZA117642 | CA52064 | SD13463 | CA52212 | 
| ZA118543 | CA52231 | IU46366 | VF90122 | 
| ZA119654 | CA52341 | GHJ3454 | ZA11199 | 
| HK233543 | LK23426 | LK34534 | ZA11275 | 
| ZA111298 | CA52086 | UJ54352 | KL678925 | 
| ZA112897 | CA52112 | PK07762 | ZA11375 | 
| ZA112777 | CA52175 | PK09123 | VF90139 | 
| ZA119057 | CA52187 | PK00264 | ZA11455 | 
| ZK012397 | GF32431 | PK09132 | VF90149 | 
| ZA112532 | CA52999 | PK09431 | VF90150 | 
| KK110998 | BB52563 | JJ09567 | FFF9016E | 
TABLE2(.dta file)
| DATA_VALUE | 
| ZA11 | 
| VF90 | 
| CA52 | 
| GF32 | 
| LK | 
| IU | 
I have two (.dta files)
I want to check the TABLE2, DATA_VALUE’s with all the elements in the TABLE1 and create a new column (Present) in TABLE1 and show 1 or 0 if the match is found (depending on the output).(and at the same time, if we don’t find the match make it as NULL)
| Column1 | Column2 | Column3 | Column4 | Present | 
| ZA112234 | CA52167 | null | VF90103 | 1 | 
| ZA114234 | CA52564 | null | VF90115 | 1 | 
| ZA115432 | CA52734 | null | CA52012 | 1 | 
| ZA116444 | CA52923 | null | CA52173 | 1 | 
| ZA117642 | CA52064 | null | CA52212 | 1 | 
| ZA118543 | CA52231 | IU46366 | VF90122 | 1 | 
| ZA119654 | CA52341 | null | ZA11199 | 1 | 
| null | LK23426 | LK34534 | ZA11275 | 1 | 
| ZA111298 | CA52086 | null | null | 1 | 
| ZA112897 | CA52112 | null | ZA11375 | 1 | 
| ZA112777 | CA52175 | null | VF90139 | 1 | 
| ZA119057 | CA52187 | null | ZA11455 | 1 | 
| ZK012397 | GF32431 | null | VF90149 | 1 | 
| ZA112532 | CA52999 | Null | VF90150 | 1 | 
| null | null | null | null | 0 | 
In SQL, we use LIKE operator to see similar strings,
Example: If we have ZA112234,
We can do this, LIKE “ZA11%”-à this will search all the values which has starts with (ZA11) ZA11xxxx.
But I don’t know how to do this in stata 16.
Any help would be greatly appreciated,
Thanks in advance
0 Response to Find value starting with a pattern ( similar to LIKE operator in SQL)
Post a Comment