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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

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
  • 3 replies
  • 1050 views
  • 0 likes
  • 2 in conversation