Re: Deleting SAS Data from a SAS DATASET #2
Chandra - this isn't my expertise area - I'm sure others may have better
ideas but I'll make three comments.
If your datasets have a large number of variables, in your datastep
method a WHERE clause will be more efficient - the IF statement causes
each record to be fully read before it can be selected for deletion. A
WHERE clause would only read the single variable in the case of records
that meet the criteria for deletion.
where snap_dt ne "&end_dt"d;
You probably would be better off changing your data model though - my
first thought would to be to store your data as separate yearly or
monthly files and then access them with a view of the past two years or
24 months. With each month or year you would delete the oldest file and
change the view one time period forward.
*set up the data;
data time1 time2 time3 time4;
do i = 1 to 100;
do t = 1 to 4;
if t=1 then output time1;
if t=2 then output time2;
if t=3 then output time3;
if t=4 then output time4;
*three successive example views;
data filet1 / view=filet1;
set time1 time2;
data filet2 / view=filet2;
set time2 time3;
data filet3 / view=filet3;
set time3 time4;
One more thought - since the data are appended - if the file is not
reordered and you have the record counts from each append - then you can
use firsto...Re: Autoexec.sas file Dm"pgm;zoom;"; doesnot wrk in SAS 9.2 #2
The PGM is the editor window up through v6.12
but also still exists today.
For the Enhanced Editor you can use:
dm editor 'zoom' wedit ;
Hope this is helpful.
Investment Business Intelligence
Investment Management & Research
Global Leaders in Multi-Manager Investing
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Ace
Sent: Wednesday, October 14, 2009 5:49 AM
Subject: Re: Autoexec.sas file Dm"pgm;zoom;"; doesnot wrk in SAS...Re: SAS data file format ?
Would the SAS System Viewer, which is free, serve your purpose?
One can download it at:
or, in short form,: http://xrl.us/oqi46
On Sun, 7 Sep 2008 13:51:44 +0200, Capra Hircus <capra.hircus@ORANGE.FR>
>> On Sep 7, 12:10 pm, Capra Hircus <capra.hir...@orange.fr> wrote:
>>> RolandRB wrote:
>>>> On Sep 7, 2:04 am, Capra Hircus <capra.hir...@orange.fr> wrote:
>>>>> I would like to know if the format specification for sas7bdat files
>>>>> available. I am currently writing some programs for statistical
>>>>> computations, and I would like to write some code to import sas
>>>>> (ultimately, it may be distributed as open source software)
>>>>> If the format is not available, is it legal to find it on my own ?
>>>> Why not convert the sas7bdat datasets to transport files within SAS
>>>> and then whatever application reads the transport files will find it
>>>> easier? I think some people are doing some work on finding out this
>>>> format but it seems pointless to me.
>>> I give the reason in the answer to R. DeVenezia. ;-)
>>> You say people try to find, does that mean it's lawful ?
>>> I'm not an exper...Re: search SAS data set from SAS code #2
The answer to your question depends on your operating system. In Windows,
there's the Search tool. In Unix/Linux, you can use grep
240 314 4400 x1374
Sent by: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
04/19/2005 11:13 AM
Please respond to myr_rose
Subject: search SAS data set from SAS code
Suppose I have a sas permanent data set which was created early, I know
the library path but I couldn't remember in which s...Re: SAS data file format ? #3
It is so nice that you'd like to be useful!
Yes, it is absolutely true that R has a problem now in reading big =
files, but it is very early in R's development; I would expect that that =
will get corrected at some point. I do agree that XML files can get to =
be very large no matter what you are reading them into, and that is =
especially a problem with R at this time. I've been writing out XML =
files to import into other things (I have a user with R, and also my end =
users want things in Excel 2007), but I do agree that XML takes time to =
write out and read into the next product. =20
A lot of the reason people did in the past keep files as SAS files =
rather than as Excel files is because they could have more columns and =
more rows than Excel previously could handle, but as of right now SAS =
can't directly import and export to an Excel 2007 format so we aren't =
over that burden yet...a Visual Basic program that read a SAS data set =
into Excel Office 2007 would probably be much appreciated by many, but I =
couldn't give you any help as to how to do it.
Good luck! Write back if you figure it out!
----- Original Message -----=20
From: Capra Hircus=20
Sent: Monday, September 08, 2008 3:33 PM
Subject: Re: SAS data file format ?
> One trend I've certainly seen in the health care industry, not just =
> SAS but also in moving data...Re: SAS data file format ? #5
Look at the SAS OleDb drivers for Windows. They are free and make SAS files
appear as an OleDb compliant datasource. SAS does not need to be installed
to use this.
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Capra
Sent: Monday, September 08, 2008 2:34 PM
Subject: Re: SAS data file format ?
> One trend I've certainly seen in the health care industry, not just in =
> SAS but also in moving data between health care systems such as IDX/GE =
> to EPIC, is to write data out as XML and then have the recieving system =
> read data in as XML. In SAS, one might write it out as follows:
> libname trans xml 'c:\temp\analysis_set.xml' xmltype=3Dgeneric =
> data trans.analysis_set;
> set work.analysis_set;
> It would seem, if you are willing to devote your time to open code,
I'd like to be useful.
> that =
> perhaps a more valuable use of your time would be to ensure that the =
> packages your users use, such as R, are able to utilize XML with =
> embedded XSD; where it is the XSD that I've found that contains the =
> metadata that defines the informats of the variables; thanks to Alan =
> Churchill for explaining this.
It's an interesting idea.
> Then you could simply export yo...Re: SAS data file format ? #4
Do those work with SAS data sets that are more than 256 fields? Can =
Office Excel 2007 import data using such a driver?
----- Original Message -----=20
From: Alan Churchill=20
Sent: Monday, September 08, 2008 3:44 PM
Subject: Re: SAS data file format ?
Look at the SAS OleDb drivers for Windows. They are free and make SAS =
appear as an OleDb compliant datasource. SAS does not need to be =
to use this.
...Re: Empty SAS data file ...how #2
you could also use:
if exist('work.empty') then do;
dsid = open('work.empty');
nobs = attrn(dsid,'nobs');
dsid = close(dsid);
thanks and regards,
...Re: convert data into SAS format #2
If you can get them into a dataset, you could do something like this =
**NOT TESTED **
if index(filename,'abc_d_') > 0; /* keep if it finds the search =
filenum + 1;
Then you can select the filename for each number in a macro:
%Do i =3D 1 %To 100 ; /* number of files */
select filename into :filename
/* then do what you want with each file using the macro variable =
%Mend processfile ;
%processfile;...Re: Unix SAS: How to save log file while in SAS session? #2
On Wed, 18 Aug 2004 12:18:03 -0500, Duck-Hye Yang <dyang@CHAPINHALL.ORG>
>I am using SAS Unix Display manager.
>I put together single small sas programming files in one giant sas
>I need to save log and output files AFTER each single small programming
>The problem is that I do not know how to save log and output while in SAS
>Below is the outline of what I'd like to do:
>DM 'clear log';
>DM 'clear output';
>SAS 1 programming start here
>x 'file "SAS...Re: running a sas file within a sas file
Like Joep wrote: that seems to be the right thing for the macro facility.
With %include you are very static. With the macro facility that could be
very dynamic. The simplest thing is: you could provide the statements you
want to insert as parameter:
stmt2=%str(if y<2 then y=2;)
with many other things you can do, e.g. conditional creating of
statements, naming variables by parameters, create multiple statements
with macro loops and much more.
On the other hand: if you want to do such simple things like you wrote,
avoid any %INC or %MACRO things!
It is far more readable, if you don't use %INCLUDES. What do you think,
that data-step will do:
if age>11 then age=11;
keep name age;
On Mon, 9 Jun 2008 01:42:03 -0700, Joep Steeman
>On 9 jun, 09:20, zpe...@NATURE.BERKELEY.EDU (Zach Peery) wrote:
>> Sorry to bug you all with such an easy one, but I havent had much luck
>> with the usual help sources.
>> I just want to run a sas program file within a sas program file. For
>> example, in sas file 1 I want to set x equal to 2, then with file 2
>> invoked by file 1, I want to set y = 3.
>> So sas file 1 looks like this...
&g...Re: SAS 9.2 Update on problem re Help files #2
SNOTES is an approximately daily email from SAS STech Support listing
the new or changed usage notes since the last email. So the item
pertaining to you was:
32792 - SAS prompts you to rebuild the index when you press F1 to
request help while running a SAS procedure in SAS 9.2
Release(s) Reported: 9.2
Date Created: 28JUL2008
Date Last Updated: 11AUG2008
To subscribe, go to
You'll get an extra email on most workdays, but if you subscribe to
SAS-L you'll hardly notice one more.
It has news about tech support office hours and a few other things.
If you want even more news, and you have an RSS reader, you can go to
On Mon, 25 Aug 2008 11:10:05 -0400 (GMT-04:00), "Peter Flom"
> Hi Jack
> I don't think I've ever looked at tech support notes ..... where is it?
> Is it useful for browsing?
> -----Original Message-----
> >From: Jack Hamilton <email@example.com>
> >Sent: Aug 25, 2008 11:08 AM
> >To: Peter Flom <firstname.lastname@example.org>, "email@example.com" <SAS-L@LISTSERV.UGA.EDU>
> >Subject: Re: [SAS-L] SAS 9.2 Updat...Re: Exporting a SAS data set to Text file on SAS unix #3
hi ... actually, what I posted earlier was too much code (sorry)
this is enough (a bit more succinct)
* variable names into a macro variable (tab separated);
proc sql noprint;
select name into :vars separated by '09'x
where libname eq 'SASHELP' and memname eq 'CLASS'
file 'z:\class.txt' dsd dlm='09'x ;
if _n_ eq 1 then put "&vars";
put (_all_) (:);
U@Albany School of Public Health
One University Place
Rensselaer, New York 12144-3456
P/518-402...Re: Reading SAS data sets on UNIX by non-SAS apps #2
Following on Richard's thoughtful suggestions, the Affinium system would
likely capture data from csv files. SAS PROC EXPORT produces them quickly,
and loading them into external systems works faster for relatively basic
data structures and data formats, in my experience, than xml parsing.
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of John
Sent: Monday, October 18, 2004 10:10 AM
Subject: Reading SAS data sets on UNIX by non-SAS apps
I have SAS data sets on AIX that we need to read with Unica's Affinium
campaign management software, also on a UNIX box. (Let's not get into why
we didn't go with the SAS Solution.) SAS Institute doesn't supply an ODBC
driver for the UNIX environment, and the Affinium implementors don't want to
use the SAS SQL Library for C and or deal with APIs. Other that dumping the
SAS data sets as flat files, can anyone suggest a solution?
Thanks in advance for the help.
...Re: What r the data types in SAS? in Base SAS , and SAS SQL
> From: Amar Mundankar
> Sent: Tuesday, July 21, 2009 8:10 AM
> To: firstname.lastname@example.org
> Subject: What r the data types in SAS? in Base SAS , and SAS SQL
> Hi all,
> What are the different data types in Base SAS and SAS SQL??
character, lengths from 1 to 32,000+
numeric: lengths from 2 to 8
dates are a subtype of numeric
and are identified by their date, datetime, or time formats
the new proc TSPL (Table Server Processing Language)
supports ANSI data types: bigint, tinyint, etc.
http://s...Re: suggest: improve SAS Deployment Wizard for SAS v9.2, phase 2 #2
> From: A Little Birdie
> I just searched the SAS-L archives (should have done that
> first) and found references to these two pages:
> Have you seen this page?
> http://support.sas.com/kb/35/631.html <---<<< NICE!
> It looks like it addresses your needs, and might be something
> nice to add to the SASCo...Re: UNIX file permissions for SAS data sets #2
Hi, Richard and everyone.
I called SAS Tech Support (919-677-8008) and got the following suggestion,
very similar to what you told me in a private communication. They
suggested editing the SAS/CONNECT script file tcpunix.scr, adding a line to
set the umask right before it issues the SAS command on the remote host,
type 'umask 022' LF;
type 'sas -dmr...
In this case, I am not using unxspawn for the remote SAS session. If I
were, I believe I would have to do what you suggested, which is to create a
shell script file with the umask command in it.
A co-worker suggested the...Re: format issue: read CSV file into SAS #2
I ran into the same problem when saving results from Microsoft SQL Server Management Studio 2005. The problem is that it saves outputs in UNICODE by default. You can change this. When saving results click on the arrow on the save button > save with encoding > set 'Available encodings' to ANSI.
Also, it may be safer to save as tab delimited. If there is a comma in the field you will have problems. Another useful feature I have found is using the coalesce function to replace 'NULL's with blanks so they import properly into SAS. If anyone knows of a better way to do this then filling your queries with coalesce functions (i.e. in SQL rather than recoding in SAS), I would be interested in the solution.
Office of Accountability
NYC Dept. of Education
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Tina MayIAsk
Sent: Wednesday, June 18, 2008 6:00 PM
Subject: format issue: read CSV file into SAS
I have a CSV file which I saved from a result generated by Transact-SQL. It looks all right. But when I imported it into SAS, all these columns turned out to have a wired looking. I tried both proc import and data step, and have the same issue.
Here is an example.
This is the CSV file.
24822326,54020 ,59016 ,1.0000
24842915,64106 ,65010 ,1.0000
24840873,54040 ,58042 ,5.0000
24843485,64007 ,65007 ,2.0000
24...Re: how to import a large cvs data file into sas #2
Without seeing code or representative input data or results, it's hard to
Does "only get one column" mean that others are lost, or that all are
concatenated together? If the latter, I suspect you are specifying the
The Import Wizard will save code for you. Tweaking that can be easier than
working from scratch.
On Wed, 29 Jun 2005 15:13:10 -0700, Dragon <yongjun.tang@GMAIL.COM> wrote:
>I have a large data file in cvs format. When I import it, I only get
>one column. When I change the format to txt, I only get either numberic
>values or char...Re: MVS Merge Variable Data Using SAS Merge or SAS SQL JOIN #2
You may want to consider using nested queries to create the keys that you
need to join the tables? That gives the SQL compiler a way to bound the
search space. For example,
create table temp as
from (select <key transformation>,* from small) as t1
left join (select <key transformation>,* from large) as t2
on t1.<transformed key> EQT t2.<transformed key>
Now the SQL compiler has two keys from the same domain that it can index or
use as sort keys. This method works with composite keys as well. Just make
sure that the <transformed key> v...Re: PC SAS 9.1
If you run SAS in batch mode the dir the .sas file is in will by default be
the dir where the .log and .lst files will be left.
Regards - Jim.
Jim Groeneveld, Netherlands
Statistician, SAS consultant
My computer remains home while I will attend PhUSE 2006 in Dublin.
On Tue, 12 Sep 2006 09:23:15 -0400, Jon Hayward <jhayward1@BABSON.EDU>
>Is there a setting in PC SAS so that whichever directory I save my .sas
>file to, SAS will automatically go there when I want to save my .log
>and .lst files?
>Currently...Re: SAS program (open data files using macro ) #2
Art has shown the answer to your question. So let's look at the design
I would prefer
%MACRO import ( path = C:\TASK3\MD , mem= , out = ) ;
PROC IMPORT OUT=&out
data _null_ ;
input mem :$char100. ;
call execute ( '%import( '
|| " mem=" || trim(mem)
|| ", out=" || "work.a" || put(_n_,5. -l)
ca...Re: R vs. SAS (was Replacement for SAS (SPSS vs. SAS, redux)) #2
Sounds like R is the SAS equivalent of Linux .. who are incidentally in all
sorts of a copy left/right mess at the moment.
On Thu, 5 Feb 2004 09:39:37 -0500, Peter Flom <flom@NDRI.ORG> wrote:
>I use both SAS and R; I"ve used SAS for 10 or 15 years, R for about 6
>months - 1 year.
>Each has strengths and weaknesses; I'd not like to give up either.
>Strengths of SAS (esp. compared to R)
>Tech support - I have SAS tech support's phone number and our license
>number memorized. They're great.
>SAS-L - There's also an R-help list...Re: How to read data from stata file(.dta) in SAS 9.0 #2
by the way: if you still get errors, install a actual SAS version. The
below is for 9.1.3
On Mon, 28 Sep 2009 10:04:31 -0400, Gerhard Hellriegel
>try the following (adapt your dataset names):
>proc import out= hsb2 datafile = "c:\data\hsb2.dta";
>proc contents data=hsb2;
>On Mon, 28 Sep 2009 00:25:37 -0700, kondal <kondal717@GMAIL.COM> wrote:
>>I used following code to read data from stata file ( SAS 9.0) bu...