sassoftware / vscode-sas-extension

This SAS Extension for Visual Studio Code provides support for the SAS language, including features such as SAS syntax highlighting, code completion, hover help, code folding, outline, SAS code snippets and run SAS code.
https://sassoftware.github.io/vscode-sas-extension/
Apache License 2.0
117 stars 47 forks source link

SAS: Libraries crash --> Element with id .SASHELP is already registered #1012

Closed Lukas67 closed 2 months ago

Lukas67 commented 4 months ago

Describe the bug After running various programs SAS libraries disappear and an error with the text "Element with id .SASHELP is already registered" appears in the bottom right corner.

Steps to reproduce SAS 9.4 and visual studio code on windows 10

Expected behavior Library visible and possible to update with data steps

Environment (please complete the following information): Client OS: Windows 10 Extension version: v1.9.0 SAS version: 9.4

scnwwu commented 4 months ago

@Lukas67, do you have steps to consistently reproduce this?

Lukas67 commented 4 months ago

Hi @scnwwu,

I think I found the cause of the error.

options symbolgen; crashes SAS libraries. Only restart of VScode temporarily fixes the bug.

Additionally I noticed that some environment variables such as SAS_EXECFILENAME are not resolved in VScode but in the standard SAS editor.

We are using a macro to unify reports across all projects.

%macro unify_optic(_t);
data _null_;
CALL SYMPUT('_RunDT', put(date(),yymmdd10.)||', '||put(time(),tod5.));
CALL SYMPUT('_RunD', put(date(),yymmdd10.));
CALL SYMPUT('_sasname', "%sysget(SAS_EXECFILENAME)");
run;

%let _Tit1=justify=left height=8pt "Project" justify=center "&_t" justify=right "Data as of &DataDate";
%let _Tit2=j=l "^{style [outputwidth=100% bordertopcolor=black bordertopwidth=.1px]}";

%let _Ftr2="^{style [outputwidth=100% borderbottomcolor=black borderbottomwidth=0.1px]}";
%let _Ftr3=justify=left height=8pt "Program: &_sasname" justify=center "Generated: &_RunDt" j = r 'Page ^{thispage} of ^{lastpage}';

Title &_Tit1;
Title2 &_Tit2;

footnote2 &_Ftr2;
footnote3 &_Ftr3;
%mend;

This macro is added with an initiator program containing options append=(sasautos="path_on_network_drive);

Interestingly the entire infrastructure works in the basic sas editor, but not in VScode.

Because of the outdated appearance and usability of the standard editor and the lack of other programming languages I would like to move to VScode.

Thanks in advance and best regards Lukas

scnwwu commented 4 months ago

@Lukas67, regarding SAS_EXECFILENAME, it is only available within the Enhanced Editor in Windows. SAS Studio, SAS Enterprise Guide and VS Code SAS extension all provide &_SASPROGRAMFILE macro variable for this purpose. Would you mind use it?

Lukas67 commented 3 months ago

Hi,

thanks for pointing that out. I resolved the macro variable with the statement (just need the programfile name in the report) for VScode: %let _sasname=%scan(&_SASPROGRAMFILE, -1, \);

Unfortunately the variable _SASPROGRAMFILE does not work in the sas editor. Can you tell me what macro variable resolves the programfile when using both VScode and SAS editor?

Furthermore another bug occured:

When specifying a footer: %let _Ftr3=justify=left height=8pt "Program: &_sasname" justify=center "Generated: &_RunDt" justify = right 'Page ^{thispage} of ^{lastpage}'; footnote3 &_Ftr3;

The report generated with VScode shows the footnote: x<R Page 1 of x@ x>

In the SAS editor the numbering works without any problems.

gl2324 commented 2 months ago

I have the same problem. Using

options symbolgen;

crashes SAS libraries. Only restart of VScode temporarily fixes the bug.

Lukas67 commented 2 months ago

I have the same problem. Using

options symbolgen;

crashes SAS libraries. Only restart of VScode temporarily fixes the bug.

Today I also checked if the problem is resolved now. Unfortunately no changes implemented.

@scnwwu Can you give us an update on the bug fixing process?

Thanks and best regards Lukas