El script utiliza la tabla `sashelp.class`, que es una tabla de ejemplo estándar provista con SAS, como fuente de datos para la macro `mf_getvarlist`. No se requieren datos externos y todos los datos de prueba se generan o provienen de SASHELP. Los resultados de las pruebas se almacenan luego en la tabla interna `work.test_results`.
1 Bloque de código
Appels de macro
Explicación : Este bloque de código realiza varias llamadas a la macro `%mf_getvarlist`. Cada llamada utiliza la tabla `sashelp.class` como entrada y varía las opciones para el delimitador (`dlm`) y el filtrado por tipo de variable (`typefilter`). Los resultados (listas de nombres de variables) se almacenan en variables macro (`test1` a `test5`) para una evaluación posterior.
Explicación : Este bloque `DATA STEP` crea la tabla `work.test_results` para registrar los resultados de las pruebas. Para cada caso de prueba, recupera el valor de la variable macro correspondiente (que contiene la lista de variables extraídas por `%mf_getvarlist`) a través de `symget()`. Luego compara este valor con una cadena de caracteres `result` predefinida que representa el resultado esperado. Se asigna un estado 'PASS' o 'FAIL' en función de esta comparación, y se registran comentarios detallados. Las variables temporales `base` y `result` se eliminan posteriormente.
¡Copiado!
data work.test_results;
length test_description $256 test_result $4 test_comments base result $256;
test_description="Basic test";
base=symget('test1');
result='Name Sex Age Height Weight';
if base=result then test_result='PASS';
else test_result='FAIL';
test_comments="Comparing "!!trim(base)!!' vs '!!trim(result);
output;
test_description="DLM test";
base=symget('test2');
result='NameXSexXAgeXHeightXWeight';
if base=result then test_result='PASS';
else test_result='FAIL';
test_comments="Comparing "!!trim(base)!!' vs '!!trim(result);
output;
test_description="DLM + quote test";
base=symget('test3');
result='"Name","Sex","Age","Height","Weight"';
if base=result then test_result='PASS';
else test_result='FAIL';
test_comments="Comparing "!!trim(base)!!' vs '!!trim(result);
output;
test_description="Numeric Filter";
base=symget('test4');
result='Age Height Weight';
if base=result then test_result='PASS';
else test_result='FAIL';
test_comments="Comparing "!!trim(base)!!' vs '!!trim(result);
output;
test_description="Char Filter";
base=symget('test5');
result='Name Sex';
if base=result then test_result='PASS';
else test_result='FAIL';
test_comments="Comparing "!!trim(base)!!' vs '!!trim(result);
output;
drop base result;
run;
1
DATA work.test_results;
2
LENGTH test_description $256 test_result $4 test_comments base RESULT $256;
3
test_description="Basic test";
4
base=symget('test1');
5
RESULT='Name Sex Age Height Weight';
6
IF base=RESULTTHEN test_result='PASS';
7
ELSE test_result='FAIL';
8
test_comments="Comparing "!!trim(base)!!' vs '!!trim(RESULT);
9
OUTPUT;
10
11
test_description="DLM test";
12
base=symget('test2');
13
RESULT='NameXSexXAgeXHeightXWeight';
14
IF base=RESULTTHEN test_result='PASS';
15
ELSE test_result='FAIL';
16
test_comments="Comparing "!!trim(base)!!' vs '!!trim(RESULT);
17
OUTPUT;
18
19
test_description="DLM + quote test";
20
base=symget('test3');
21
RESULT='"Name","Sex","Age","Height","Weight"';
22
IF base=RESULTTHEN test_result='PASS';
23
ELSE test_result='FAIL';
24
test_comments="Comparing "!!trim(base)!!' vs '!!trim(RESULT);
25
OUTPUT;
26
27
test_description="Numeric Filter";
28
base=symget('test4');
29
RESULT='Age Height Weight';
30
IF base=RESULTTHEN test_result='PASS';
31
ELSE test_result='FAIL';
32
test_comments="Comparing "!!trim(base)!!' vs '!!trim(RESULT);
33
OUTPUT;
34
35
test_description="Char Filter";
36
base=symget('test5');
37
RESULT='Name Sex';
38
IF base=RESULTTHEN test_result='PASS';
39
ELSE test_result='FAIL';
40
test_comments="Comparing "!!trim(base)!!' vs '!!trim(RESULT);
41
OUTPUT;
42
43
drop base RESULT;
44
RUN;
Este material se proporciona "tal cual" por We Are Cas. No hay garantías, expresas o implícitas, en cuanto a la comerciabilidad o idoneidad para un propósito particular con respecto a los materiales o el código contenidos en este documento. We Are Cas no es responsable de los errores en este material tal como existe ahora o existirá, ni We Are Cas proporciona soporte técnico para el mismo.
Información de copyright : Copyright 2010-2023 HMS Analytical Software GmbH, http://www.analytical-software.de. Este archivo es parte de SASUnit, el framework de prueba unitaria para programas SAS(R). Para información de copyright y condiciones de uso bajo la licencia pública general limitada GNU, vea el archivo incluido README.md o https://github.com/HMS-Analytical-Software/SASUnit/wiki/readme/.
SAS y todos los demás nombres de productos o servicios de SAS Institute Inc. son marcas registradas o marcas comerciales de SAS Institute Inc. en los EE. UU. y otros países. ® indica registro en los EE. UU. WeAreCAS es un sitio comunitario independiente y no está afiliado a SAS Institute Inc.
Este sitio utiliza cookies técnicas y analíticas para mejorar su experiencia.
Saber más.