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
9**/
10
11filename csvref temp;
12
13data _null_;
14 file csvref;
15 put 'id,name,amount';
16 put '1,alpha,10';
17 put '2,beta,20';
18 put '3,gamma,30';
19run;
20
21/* the base dataset supplies the variables the CSV is loaded into */
22data work.csv_base;
23 length id $10 name $20 amount $10;
24 call missing(of _all_);
25 stop;
26run;
27
28%mp_csv2ds(inref=csvref,outds=work.csv_out,baseds=work.csv_base)
29
30proc sql noprint;
31 select count(*) into: n_rows from work.csv_out;
32 select name into: first_name from work.csv_out(obs=1);
33quit;
34
35%mp_assert(
36 iftrue=(&n_rows=3),
37 desc=Checking that every row of the csv is loaded,
38 outds=work.test_results
39)
40
41%mp_assert(
42 iftrue=(%sysfunc(strip(&first_name))=alpha),
43 desc=Checking that the first data row is stored under the header variable,
44 outds=work.test_results
45)