I have no idea how you want to do this, nor why to be honest, but this will work.
<SCRIPT LANGUAGE='javascript">
<!--
var sid = <?php echo $sid; ?>;
//-->
</SCRIPT>
As long as PHP has assigned a value to $sid, and you save the javascript as a file with .php, or .inc, whatever extension you like, then use include, or require to call it, it will work. For that matter, as long as the variable is set before the script gets parsed to the page, it will work.
I use this exact method for a stats tracking script and it works perfectly. If it is not working for you, then the problem lies elsewhere. If you are calling the file from within a function, you have to set $sid as a global or it will not pass the variable to the file when you include it.