Why am I unable to access SAS Library - sas

I am running the following code in SAS EG:
Data sashelp.air;
proc sgplot data=sashelp.air;
histogram AIR /;
yaxis grid;
run;
ERROR: User does not have appropriate authorization level for library SASHELP.

That error is most likely because of this statement:
Data sashelp.air;
What that statement does (when it runs) is to tell SAS to overwrite the dataset sashelp.air with a new dataset, which has no other statements - so it would overwrite it with an empty dataset with no columns.
Fortunately, you don't have write permission to the sashelp library, so that fails.
Remove the line, and only run the proc sgplot, and it should work. If that still gives you an error, then talk to your SAS administrator.

Related

Error while loading data in Teradata using proc append (SAS EG 14.1)

I am getting below error while appending data in a Teradata table from SAS
ERROR: Teradata connection: No more room in database TINYDB. Correct error and
restart as an APPEND process with option TPT_RESTART=YES. Since no checkpoints were
taken, if the previous run used FIRSTOBS=n, use the same value in the restart.
I don't know why i am getting this error for one table, because i am able to append other Teradata tables.
I am using simple proc append
proc append data=table1 base=table2 (MULTILOAD=YES TPT=YES) force;
run;
Please suggest why its giving above error just for one table, while appending in other Teradata tables is working fine.
Thanks
#
Adding
Just one explanation, if i remove (MULTILOAD=YES TPT=YES) from the Proc Append Statement, then it will work, but will take huge amount of time

How to get SAS tables sizes and last usage time in library

Good day!
I need a list of libraries-tables on a SAS server with a size of each table and last time, when it was open/used.
I'm not very familiar with SAS, so I don't even know where would I start searching :(
I assume, that there is some simple solution, maybe a proc of some sort, that may help...
You can use proc contents to access metadata about a library in SAS, for example using the sashelp library:
proc contents data = sashelp._ALL_ NODS;
run;
sashelp is the library you are refencing. By specifying _ALL_ you ask SAS for data about all the files in this library (by choosing a singular file such as sashelp.ztc you can get information on jut one file).
This will give you a lot of information, so by using the NODS statement you can suppress the output to give you less detail. The above code will give you the number of files, their type, the level, the file size, and the data they were last modified.
If you want to output this information to a dataset, you have to use the ODS output system with the correct ods table name, in this case it is Members. Furthermore, if you're looking for datasets in particular then you can filter the output with a where= statement:
ods output Members = test (where = (memtype = "DATA"));
proc contents data = work._ALL_ NODS noprint;
run;
ods listing; /* change back to listing output*/

SAS Proc UCM output breakpoints

I have a timeseries dataset in SAS and I am running this data through the UCM procedure to identify signficiant structural breakpoints in the timeseries (changes in the expected mean).
My code is as follows:
proc ucm data=temp;
by source;
id date interval=month;
model baseload;
irregular;
level checkbreak;
run;
The level checkbreak statement above is printed in the SAS output window in the section labeled 'outlier summary', but I need the output in a dataset. The 'outest' statement only works for the 'estimate' statement and not the level statement in proc UCM. Does anyone know know if it is possible to write this section out to a dataset?
You can access the OutlierSummary table using SAS's ODS system.
Read about it here:
http://support.sas.com/documentation/cdl/en/etsug/60372/HTML/default/viewer.htm#etsug_ucm_sect034.htm

How to create "standardized" Excel workbooks using SAS

I have a "wide" SAS data sets that must be exported into a new Excel workbook every week. I want to preserve the column widths and other Excel attributes every week, but I'm having problems getting it to work. Here's what I'm attempting.
I used PROC EXPORT to create a new workbook (using sheet="New_TACs").
I manually adjusted the column widths and other sheet attributes
(like "filters", column widths, wrap, alignment, and "freeze panes").
I deleted all the data rows (leaving the first row with the column
names) and saved it as a new workbook named "template.xlsx".
Using a SAS system call, I copy "template.xlsx" to "this_week.xlsx".
I use PROC EXPORT again to try and update the new workbook, but I
get warnings. The result contains a sheet named "New_TACS1".
Here is the SAS log:
720 proc export data=new_tacs
721 outfile="\\server-path\this_week.xlsx"
722 replace;
723 sheet='New_TACs';
724 run;
WARNING: The target file may contain unmatched range name and sheet name.
WARNING: The target file may contain unmatched range name and sheet name.
WARNING: File _IMEX_.New_TACs.DATA does not exist.
WARNING: Table _IMEX_."New_TACs" has not been dropped.
NOTE: "New_TACs" range/sheet was successfully created.
NOTE: PROCEDURE EXPORT used (Total process time):
real time 23.88 seconds
cpu time 1.80 seconds
I'm at a loss as to what to do and would appreciate any ideas or suggestions.
I think the issue is that with zero rows, SAS isn't properly dealing with the data. I can't get PROC EXPORT to work at all, but with a single dummy row I can at least get it to behave with libname and PROC APPEND. I wouldn't be surprise if the filters are in part responsible for this.
After creating the blank excel file with the SASHELP.CLASS columns, adding a filter, adding one row of dummy data, and saving/closing, I do: (SCANTEXT=NO is mandatory here for update access)
libname newtac "c:\temp\test.xlsx" scantext=no getnames=yes;
proc append base=newtac.'New_TACs$_xlnm#_FilterDatabase'n data=sashelp.class force;
run;
libname newtac clear;
That gets close, at least. I'm getting some blank rows for some reason, perhaps due to other things I did in looking at this.
Your best solution may well be to wait for 9.4 TS1M0 and ODS EXCEL, which will let you do all these things from SAS directly; or to use DDE.
I would recommend checking out SaviCells. http://www.sascommunity.org/wiki/SaviCells. It provides much better SAS to Excel functionality, including creating a template with all your Excel formatting and using that with new data.
Use DDE in SAS to achieve this.
You can create your excel template the way you want it to appear.
Using DDE you would then:
Open Excel
Open the excel file you want to use as the template
Populate it with the updated data
Save the file as a new filename
It's a bit of an antiquated technology but it gets the job done.
Googling for SAS and DDE will find you plenty of code exmaples and tutorials.

Can I get some default/empty text to display if a PROC REPORT doesn't generate due to no valid data?

I have a SAS program that loops through certain sets of data and generates a bunch of reports to an ODS HTML destination.
Sometimes, due to small sets of data I run these reports for, a certain PROC REPORT will not generate because, for this set of data I'm on, there is no data to report. I get this message for those instances:
WARNING: A GROUP, ORDER, or ACROSS variable is missing on every observation.
What I want in the HTML is to display some sort of message for these like "did not generate" or something.
I tried to use return/error codes or the warning text above to detect this, but the error code is 0 (no problem, really?) and the warning text doesn't reset if the next PROC REPORT generates OK.
If it is of any importance, I'm using a data step with CALL EXECUTE to get all this PROC REPORT code generated for these sets of data.
Is there any way to generate this "did not generate" message or at least to catch these warnings per PROC REPORT?
You can substitute in a value for the missing observations in your report.
First redefine missing values to some character. I think you can only use a single character, I could be wrong, though.
options missing='M';run;
Then make sure to use the "missing" option in your PROC REPORT.
proc report data=somedata nowd headline missing;
....
run;
EDITS BASED ON COMMENTS
To get comments to show up, I see a few possibilities.
One, scan the the data set and check for missing values. If any are present throw a message out.
Data _Null_;
Set dataset;
file print notitles;
if obs = . then do;
put #01 'DID NOT COMPUTE';
stop;
end;
run;
Two, add a column with a compute:
define xx /computed "(Message)";
compute xx /char length=16 ;
if obs =. then xx = 'did not compute value in row';
Three, a conditional line using compute:
compute after obs;
if obs = . then do;
line #1 "DID NOT COMPUTE";
end;
endcomp;
endcomp;
See: http://www2.sas.com/proceedings/sugi26/p095-26.pdf
Look for the MTANYOBS macro and the section on printing a 'no observations' page.