Desktop productivity for business analysts and programmers

macro var not resolved in filenam

Reply
New Contributor
Posts: 3

macro var not resolved in filenam

[ Edited ]

Hi all. 

 

 ***********************UPDATED LOG****************************

 

I am trying to read monthly CSV files into SAS each month. But the macro is not readable in filename statement. Please take a look at the code to see what I am missing.

 

DATA _NULL_;
tday = INTNX('month',today(),-2,'B');
CALL SYMPUT('chknm',PUT(tday,monyy5.));
RUN;
%put &chknm.;

filename btv1 FTP "/CustomerDelivery/btv/&chknm.._chk2.csv"
host = "&nthost"
user = "&ntid"

 

 And this is the LOG from the code above...

 

21 %put &chknm.;
JAN18
22
23 filename btv1 FTP "/CustomerDelivery/btv/&chknm.._chk2.csv"
24 host = "&nthost"
25 user = "&ntid"

 

 

Thanks!!

Super User
Posts: 13,941

Re: macro var not resolved in filenam

So, Which did you submit:

filename btv1 FTP "/CustomerDelivery/btv/&chknm.._chk2.csv"

or (from log)

filename btv1 FTP "/CustomerDelivery/btv&chknm.._chk2.csv"

 

one of these is not like the other. A missing / would be very critical in finding the file.

 

Your log is incomplete as you do not show the end of the filename statement or any message about success or failure.

 

If you want to see the resolved values use

Options mprint;

before the code and then

Options nomprint;

to stop the resolution in the log.

New Contributor
Posts: 3

Re: macro var not resolved in filenam

Updated the log. it was with "/"

 

18 DATA _NULL_;
19 tday = INTNX('month',today(),-2,'B');
20 CALL SYMPUT('chknm',PUT(tday,monyy5.));
21 RUN;

NOTE: DATA statement used (Total process time):
real time 0.06 seconds
user cpu time 0.01 seconds
system cpu time 0.01 seconds
memory 738.15k
OS Memory 19616.00k
Timestamp 03/27/2018 01:42:05 PM
Step Count 12 Switch Count 30
Page Faults 0
Page Reclaims 133
Page Swaps 0
Voluntary Context Switches 111
Involuntary Context Switches 21
Block Input Operations 0
Block Output Operations 0

22 %put &chknm.;
JAN18
23
24 filename btv1 FTP "/CustomerDelivery/btv/&chknm.._chk2.csv"
25 host = "&nthost"
26 user = "&ntid"
27 pass = "&ntpwd"
28 WAIT_MILLISECONDS=1000000;
29
30 Options nomprint;
31

Super User
Super User
Posts: 8,279

Re: macro var not resolved in filenam

You defined a FILENAME, but you haven't done anything with it yet.

Were you going to try to read that file? Or write to it?

Respected Advisor
Posts: 4,795

Re: macro var not resolved in filenam

@jkim1012

Additionally to what @Tom wrote: Why are there two dots after &chknm. Is the filename you're after really JAN18._chk2.csv

 

22 %put &chknm.;
JAN18
23
24 filename btv1 FTP "/CustomerDelivery/btv/&chknm.._chk2.csv"
Ask a Question
Discussion stats
  • 4 replies
  • 156 views
  • 0 likes
  • 4 in conversation