The data is entirely created internally within the script via `datalines` in the first `DATA STEP`. The second `DATA STEP` uses the previously created dataset.
1 Code Block
DATA STEP Data
Explanation : This `DATA STEP` block creates a temporary dataset named `test_email`. It reads email addresses provided directly in the script via `datalines`. The `email` variable is defined as a character with a maximum length of 32.
Copied!
data test_email;
informat email $32.;
input email;
datalines;
test @test.fr
Test @test.fr
test @test..fr
.test @test.fr
.test @@test.fr
test @code_sas_json/marktest.json @test.fr
1.test @test.fr
n.test @test.fr
;
run;
1
DATA test_email;
2
informat email $32.;
3
INPUT email;
4
DATALINES;
5
test @test.fr
6
Test @test.fr
7
test @test..fr
8
.test @test.fr
9
.test @@test.fr
10
test @code_sas_json/marktest.json @test.fr
11
1.test @test.fr
12
n.test @test.fr
13
;
14
RUN;
2 Code Block
PROC FCMP
Explanation : This `PROC FCMP` block defines a custom function named `CheckMail`. It is stored in the `work.cat_function` library under the `test` entry. The function takes an `Email` argument (character string), converts it to lowercase, then uses `PRXMATCH` with a regular expression to check the validity of the email address format. `PRXMATCH` returns the match position if found, or 0 otherwise. This result (0 or >0) is returned by the function.
Explanation : This second `DATA STEP` reads the `test_email` dataset created previously. For each observation, it calls the `CheckMail` function with the email address and stores the validation result (0 or 1) in a new numeric variable `Cmail`.
Copied!
data test_email;
set test_email;
Cmail=CheckMail(email);
run;
1
DATA test_email;
2
SET test_email;
3
Cmail=CheckMail(email);
4
RUN;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
Copyright Info : Creation date : 09/04/2017 (fr)
Last update : 09/04/2017 (fr)
Author(s) :
Contributor(s) :
Tested on SAS Studio 9.4
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.