Intellisense in SAS - sas

Is there an option to enable IntelliSense in PROC SQL SAS enterprise guide?eg. Autofil Table names, Columns etc. Also highlights errors in code like missing ; etc.
Thank you

Related

SAS studio - formatting

I am attempting to format variables in SAS studio which have been truncated due to the name being longer than 32 characters, when I attempt to format the variables in SAS studio it gives the warning 'this variable in uninitialized'. when I run the same code in SAS EG against the same excel document imported, the code works fine and formats the variable. Why would the same code in SAS studio not work?
code:
data test;
set test1;
format 'variable'n best12.;
run;
Compare the value of option VALIDVARNAME in EG vs Studio. Set it in studio to the same as EG.
Two common ways to view the current setting of an option. Proc OPTIONS or function GetOption
proc options option=validvarname;
run;
%put %sysfunc(getoption(validvarname));
The code won’t be the same because you’re using two different applications with different default settings most likely. As someone else indicated, it’s likely the validvarname option that’s the issue. I would recommend setting it to V7 which avoids these issues. With this setting, SAS converts them to valid variable names by default and you can avoid the rename step entirely.
Supposedly the 32 char limit will be lifted in SAS 9.5. No release date has been announced, SAS 9.4 M5 was recently released so I’m not expecting it super soon.

SAS : ODS and code highlighting

When using R markdown for making statistical reports, I have the ability to echo the R code in my output document. I'm learning SAS and I was wondering if it was possible to highlight or echo the SAS code in my final ODS report ? I'm using a dirty hack right know to display the code in my document, which is using "ods text = ", but it seems quite redundant. Plus it doesn't add syntax highlighting.
That feature does not exist in the SAS language right now, but it has been mentioned in several talks by Amy Peters, principal product manager of the SAS programing environments, as a planned feature for a near-future SAS release (with no specific date yet, but hopefully in the next 2 years). It would likely be implemented in a similar fashion to Jupyter Notebooks, in that you write your code and get your output inline.
That said, SAS does support Jupyter Notebooks, which is the best current (third party) solution. Contact your SAS administrator for more information.
I have an idea here, I'm the type of guy who dosent take no for answer and find a way to fiddle and get it done... but i think this is abit far fetch... you can try still I think it will work with mostly evrything but may have a hard time to play with quotes when you have multiple semi colomns....
Check:
I started by creating a dumbass dataset :
data tata;
x=1;
run;
then we do the following:
%let code= select * from tata;
proc sql;
create table report as
&code.;
quit;
proc print data=report;
footnote "&code.";
run;
The rationale:
I think it you put your code in macrovariables and then execute those macro variables you would be able to print show the code after by printing the macrovariable following your text...
See the sample

How to find SAS version from SAS Enterprise Guide?

In my previous work place where I had access to base SAS (running SAS interactively on the server directly), I could find out the current SAS version easily (from the SAS log) by issuing the code proc setinit; run;
In my new work place there is no base SAS - only Enterprise Guide. I try running the same code but the SAS version does not appear in the SAS log.
I would like to easily find out the SAS version running on the server from Enterprise Guide. Is this possible or not? If so, how?
The values you're looking for are stored in automatic macro variables in your system. The code below retrieves the macro variables and prints them to the log for your information.
%put ** my information;
%put short version: &sysver;
%put version: &sysvlong4;
%put site #: &syssite;
%put cpu: &sysscp &sysscpl;
EDIT: Update answer
You can use PROC PRODUCT_STATUS which is great, since it will print the relevant information to the log.
proc product_status;run;
There are some other options available rather than using the global macro variables (&sysver and &sysvlong4), if you prefer point-click options.
First, under Help -> About SAS Enterprise Guide, if you select 'Configuration Details' you can see your SAS system version.
Second, if you select the server in the Servers tree (in the window on the bottom left), and right click->Properties, you will see the SAS version/etc. information.
Third, if you continue in that and select "View Initialization Log", it will show you the initialization log (the bit SAS shows when you start a session in the log). This includes the version number and some other useful information.
Just run the following code and all available information will be printed automatically.
proc setinit;
run;
You can also use
%put _all_;
that will display all macro variables available in your session.
proc setinit;
run;
You can run this set of code and check the results. It will tell you the version you are using.
%put &_clientversion; gives you version.
proc setinit;
run;
Or under the help tab in the top left of the enterprise guide.

how to get the return codes from SAS pass-through SQL to Teradata ?

In SAS 9.2, how do I get the return codes / error messages from explicit pass-through sql to teradata? Printed in log or output or something.
I already got a small query to work fine, but having some trouble with a more complex one. Debugging would be much easier with the error messages.
Tried the sqlxmsg and sqlxrc that are used when querying db2, but of course those don't work... haven't found any documentation on this. (I'm quite new to Teradata)
Use the SASTRACE option to bring back debugging messages from Teradata.
http://support.sas.com/documentation/cdl/en/acreldb/63647/HTML/default/viewer.htm#a000433982.htm
This document supports and shows an example of it in use on explicit pass-through SQL:
https://support.sas.com/resources/papers/TroubleshootingSASandTeradataQueryPerformanceProblems.pdf
N.B. If you are using this option on large sets of data, be careful to choose the options wisely or you will create huge logs
This was the code, and now after shutting and restarting SAS it works fine!
Seems I had some process hanging somewhere...
rsubmit sashost;
proc sql;
connect to teradata (user=&terauser password=&terapass server=&teraserv mode=teradata);
create table test as
select * from connection to teradata
(select x
from y.z
where c);
%put &sqlxmsg;
%put &sqlxrc;
disconnect from teradata;
quit;
proc download data=test out=locallib.test; run;
endrsubmit;

How do you tell what index is being used in SAS proc sql? Is there an explain equivalent?

Is there an equivalent to EXPLAIN in SAS Proc SQL? From Google searches I've done, it doesn't seem like it.
Actually, what I really need to know is how to tell if an index was used during a JOIN or which index the query ended up using.
Thanks in advance.
OPTIONS MSGLEVEL=I;
will tell you when an index is used (and which), for SQL or data step.
Example:
data class(index=(sex));
set sashelp.class;
run;
options msglevel=i;
proc sql feedback;
select * from class where sex='M';
quit;
FEEDBACK and STIMER are useful PROC SQL options that will also give you more information about the query you wrote ( http://support.sas.com/documentation/cdl/en/sqlproc/62086/HTML/default/viewer.htm#a001360938.htm)
Edit:
https://communities.sas.com/thread/14072?start=0&tstart=0
Apparently there IS an explain option, though it's undocumented and still a work in progress. See the link for more details.