Help using Base SAS procedures

Creating Dynamically named output files

Not applicable
Posts: 0

Creating Dynamically named output files

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;
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,
Super Contributor
Super Contributor
Posts: 3,176

Re: Creating Dynamically named output files

Posted in reply to deleted_user
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.
Not applicable
Posts: 0

Re: Creating Dynamically named output files

Ah yes. I forgot to send the sas messages Smiley Very Happy

NOTE: Variable tempeof is uninitialized.
NOTE: Variable out is uninitialized.
NOTE: The infile TEMP2 is:
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:
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
Not applicable
Posts: 0

Re: Creating Dynamically named output files

Posted in reply to deleted_user
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!
Ask a Question
Discussion stats
  • 3 replies
  • 2 in conversation