BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hey folks,
I am trying to create some dynamically named HTML files from our crash intersection data (one html page per intersection), and I'm having real difficulty getting sas to understand what my file should be called. The name is generally , where CITY = the city, and INTERSECTION = the name of the two roads crossing each other.

Here is my code right now (I've tried several permutations):

fName = compress("\\Dgrfs-0/pgms/tsb/upid7/upid7_html/&cityName._") || compress(compress(scan(fileStart2, 3, '<>'),'&')) || ".html";
putlog fName;
rc=filename("out",fName);
file out lrecl=&linesize. notitle noprint;

So the idea is that out will change dynamically to the new file name. The reality is that out.dat and fName.dat get created instead.

Also, this can't be done in the macro step because my intersections are dynamically created in my data, and not pre-known.

Any ideas?

Thanks much,
-Jim
3 REPLIES 3
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
You should be able to test your logic and observe the SAS-generated results with a simple standalone DATA step. Also, it's unclear what the exact file-name format is expected to be, mostly because we don't see any SAS-generated log information revealing the code/text substitution.

Scott Barry
SBBWorks, Inc.
deleted_user
Not applicable
Ah yes. I forgot to send the sas messages 😄

NOTE: Variable tempeof is uninitialized.
NOTE: Variable out is uninitialized.
NOTE: The infile TEMP2 is:
Filename=\\Dgrfs-0\pgms\tsb\upid\upid7_html\tempFile.txt,
RECFM=V,LRECL=200,File Size (bytes)=4999,
Last Modified=12May2010:11:25:30,
Create Time=15Apr2010:11:38:30

ERROR: Physical file does not exist,
\\Dgrfs-0\pgms\tsb\upid7\upid7_html\Taos_PaseoDelCanonPaseoDelPuebloSur.html. <----- Interpreted and correct filename that I'm trying to create.
NOTE: The file FNAME is:
Filename=\\Dgrfs-0\pgms\tsb\upid\fname.dat,
RECFM=V,LRECL=200,File Size (bytes)=0,
Last Modified=12May2010:11:25:31,
Create Time=12May2010:10:19:24

NOTE: 0 records were read from the infile TEMP2.
NOTE: 0 records were written to the file FNAME.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
real time 0.04 seconds
cpu time 0.01 seconds
deleted_user
Not applicable
I have solved it. The file name is too long (though the error messages don't report this issue, just that the file doesn't exist).
Thanks for your help!
-Jim

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1086 views
  • 0 likes
  • 2 in conversation