BookmarkSubscribeRSS Feed
jbs23
Calcite | Level 5

What im trying to do is load some txt plain.

%let DIR_IN_BASE=I:\SGEE\SGEE\Jorge\Proyecto\ENTRADA; 
%let DIR_OUT_BASE=I:\SGEE\SGEE\Jorge\Proyecto\SALIDA;

%let RUT_IN=&DIR_IN_BASE;

%let FILE_TIT_IN=fp;
%let FILE_TIT_OUT=fichero_fp_salida;

%let CURSO=17;

**nombre variables;
%let PERIODO_REF_ACT = cursoacademico;
%let COD_TIPO_DOCU = tipodocumento;
%let ID_DOCUMENTO = documento;
%let COD_SEXO = sexo;
%let COD_GRUPO_EDAD = grupoedad;
%let COD_TIPO_ACT = curso;
%let COD_CENTRO = centro;
%let COD_SITUAC_SOCIO = situacionsocial;
%let COD_SITUAC_ACTIV = situacionlaboral;
%let FECHA_ENTR_ACT = entrada;
%let FECHA_SAL_ACT = salida;

libname fp_out "&DIR_OUT_BASE";

%macro mImport_txt(FILE_IN=,FILE_OUT=);
DATA &FILE_OUT; 
INFILE &FILE_IN pad lrecl=5000;
INPUT   
		@1 &cursoacademico 4.
		@5 &tipodocumento 1.
		@6 &documento $ 9.
		@15 &sexo 1.
		@16 &grupoedad 2.
		@18 &curso 3.
		@21 &centro 8.
		@29 &situacionsocial 1.
		@30 &situacionlaboral 1.
		@31 &entrada $ 8.
		@39 &salida $ 8.;
RUN;
%mend mImport_txt;

%mImport_txt(FILE_IN="&RUT_IN.&FILE_TIT_IN..txt",FILE_OUT=&FILE_TIT_IN._&CURSO);

And the error is this

 

15         %mImport_txt(FILE_IN="&RUT_IN.&FILE_TIT_IN..txt",FILE_OUT=&FILE_TIT_IN._&CURSO);
22: LINE y COLUMN no se pueden determinar.
NOTE 242-205: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN 
              where the error has occurred.
ERROR 22-322: Expecting a name.  
WARNING: Apparent symbolic reference CURSOACADEMICO not resolved.
22: LINE y COLUMN no se pueden determinar.
NOTE 242-205: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN 
              where the error has occurred.
ERROR 22-322: Expecting a name.  
WARNING: Apparent symbolic reference TIPODOCUMENTO not resolved.
22: LINE y COLUMN no se pueden determinar.

thanks for all!

4 REPLIES 4
Kurt_Bremser
Super User

When you do this:

%let PERIODO_REF_ACT = cursoacademico;

you set the macro variable PERIODO_REF_ACT to the value cursoacademico.

When you do this:

INPUT   
		@1 &cursoacademico 4.

you are trying to reference the macro variable cursoacademico, which does not exist.

 

Why do you want to use different variable (column) names, when the files have apparently the same structure?

MarkDawson
SAS Employee

Hi,

 

The reason for the errors is because macro variables like cursoacademico are not set.  There are two possibilities...

 

Either your %LETs were wrong, so where you had...

 

   %let PERIODO_REF_ACT = cursoacademico;

 

You should have had

 

   %let cursoacademico = PERIODO_REF_ACT ;

 

Or your input statement used the wrong macro variable name, so

 

   @1 &cursoacademico 4.

 

should have been

 

   @1 &PERIODO_REF_ACT 4.

 

Once you know which you really need you can change all the others in the same way.

 

Mark

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Why do you have all the macro code?  As I mention in your other post.  To import a file you do a simple:

data want;
  infile...;
  informat...;
  format...;
  length...;
  input...;
run;

You will see from the above there is no % this or & that, just plain simple Base SAS code.  This is the place to start (and in 99% of cases stop).  Do not get into the habbit of using macro just for the sake of using, it does not add anything to the code and makes it far less reliable and harder to maintain, especially when you consider the code presented has no need for the macro whatsoever.

ShiroAmada
Lapis Lazuli | Level 10

I think it's because of this

%let DIR_IN_BASE=I:\SGEE\SGEE\Jorge\Proyecto\ENTRADA;

change it to this

%let DIR_IN_BASE=I:\SGEE\SGEE\Jorge\Proyecto\ENTRADA\;

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 792 views
  • 2 likes
  • 5 in conversation