Stata 15 help for _getfilename


[P] _getfilename -- Utility commands for handling path-filename specifications


_getfilename `"path-filename"'

_shortenpath `"path-filename"', len(#) [ head(str) ]


_getfilename returns in r(filename) the name of the file (with extension), stripping off drive and directory information. Also see [P] findfile for a related command.

_shortenpath returns in r(pfilename), a shortened path-filename string of length at most len. Shortening is accomplished by replacing leading directories by one *, denoting `some string'. _shortenpath never shortens the filename itself, and leading directories are represented by a string at least as long as *\, so _shortenpath may actually return a string longer than len.


len(#) (_shortenpath only) is not optional. It specifies the length to which the path-filename should be shortened.

head(#) (_shortenpath only) specifies the string used to represent the leading directories removed from the head of path-filename. It defaults to *.


. _getfilename c:\archive\stata\data\hin95.dta r(filename): hin95.dta

. _shortenpath c:\archive\stata\data\hin95.dta, len(20) r(pfilename): *\data\hin95.dta

. _shortenpath c:\archive\stata\data\hin95.dta, len(5) r(pfilename): *\hin95.dta


These utilities were written by Jeroen Weesie, Dept of Sociology, Utrecht University, The Netherlands.

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index