Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
mp_csv2ds.test.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief Testing mp_csv2ds macro
4
5 <h4> SAS Macros </h4>
6 @li mp_csv2ds.sas
7 @li mp_assert.sas
8 @li mp_assertmodel.sas
9
10**/
11
12filename csvref temp;
13
14data _null_;
15 file csvref;
16 put 'id,name,amount';
17 put '1,alpha,10';
18 put '2,beta,20';
19 put '3,gamma,30';
20run;
21
22/* the base dataset supplies the variables the CSV is loaded into */
23data work.csv_base;
24 length id $10 name $20 amount $10;
25 call missing(of _all_);
26 stop;
27run;
28
29%mp_csv2ds(inref=csvref,outds=work.csv_out,baseds=work.csv_base)
30
31%mp_assertmodel(work.csv_out,base=work.csv_base,key=id,
32 desc=Checking the CSV output model and id key,
33 outds=work.test_results
34)
35
36proc sql noprint;
37 select count(*) into: n_rows from work.csv_out;
38 select name into: first_name from work.csv_out(obs=1);
39quit;
40
41%mp_assert(
42 iftrue=(&n_rows=3),
43 desc=Checking that every row of the csv is loaded,
44 outds=work.test_results
45)
46
47%mp_assert(
48 iftrue=(%sysfunc(strip(&first_name))=alpha),
49 desc=Checking that the first data row is stored under the header variable,
50 outds=work.test_results
51)