Re: Create SAS file from raw data
input A $ 1-5;
input Test $ 1 @@;
do while (Test eq ' ');
input B C:$2. D:$8. E:$5. F G H / I J:$3. K:$3. L:$3.;
input Test $ 1 @@;
J S Huang
>>> "Li,Qian [Ontario]" <Qian.Li@EC.GC.CA> 12/8/2005 12:12:14 PM >>>
I have to create a SAS file from a raw data formatted as following:
9.44240 O3 P CNSAPR02 12002 1 1 20020501.00000000
20020501.01000000 001 001 001
2.72953 O3 P CNSAPR02 12002 2 2 20020501.00000000
20020501.02000000 001 001 001
2.37352 O3 P CNSAPR02 12002 3 3 20020501.00000000
20020501.03000000 001 001 001
1.86168 O3 P CNSAPR02 12002 4 4 20020501.00000000
20020501.04000000 001 001 001
1.25260 O3 P CNSAPR02 12002 5 5 20020501.00000000
20020501.05000000 001 001 001
0.70932 O3 P CNSAPR02 12002 6 6 20020501.00000000
20020501.06000000 001 001 001
0.57959 O3 P CNSAPR02 12002 7 7 20020501.00000000
20020501.07000000 001 001 001
0.88178 O3 P CNSAPR02 12002 8 8 20020501.00000000
20020501.08000000 001 001 001
1.37837 O3 P CNSAPR02 12002 9 9 20020501.00000000
20020501.09000000 001 001 001
1.71653 O3 P CNSAPR02 12002 10 10 20020501.00000000
20020501.10000000 001 001 001
0.85449 O3 P CNSAPR02 12002 11 11 20020501.00000000
20020501.11000000 001 001 001
1.17...Re: how to import a large cvs data file into sas
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
> values or characters. Is there any easy way out? Thank you!
I'm not quite sure what you're asking. So let me ask you a
few clarifying questions.
Are you using PROC IMPORT? If not, what are you using?
Do you have one or more columns with mixed (some numeric
and some character) data?
You say you 'get' only 1 column. How many columns do you
have? How many of them have 'mi...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 characters. Is there any easy way out? Thank you!
...Re: sas data file --> excel file
I wrote a paper on doing this using Visual Studio Express for C# and reading
the SAS dataset using OleDb. You can find the paper with step-by-step
Several people have followed the steps with no issues.
Savian "Bridging SAS and Microsoft Technologies"
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Mindy
Sent: Tuesday, November 15, 2005 4:27 PM
Subject: sas data file --> excel file
Does any one know an easy way of transfer sas data file to excel file
except EXPORT? we have DBMS engine, which is really easy to read excel
file to SAS, but I don't know if that engine is helpful to export SAS
data file to excel file. Any comments are welcome.
...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: 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: Executing separate SAS File from Main SAS File
[mailto:firstname.lastname@example.org]On Behalf Of
Sent: Tuesday, August 02, 2005 2:42 PM
Subject: Executing separate SAS File from Main SAS File
I was wondering if I can initiate execution of SAS code stored in a SAS
file from my main SAS code. Help very much appreciated.
This e-mail may be privileged and/or confidential, and the sender does not waive any related rights and obligations.
Any distribution, use or copying of this e-mail or the information it contains by other than an intended recipient is unauthorized.
If you received this e-mail in error, please advise me (by return e-mail or otherwise) immediately.
Ce courrier �lectronique est confidentiel et prot�g�. L'exp�diteur ne renonce pas aux droits et obligations qui s'y rapportent.
Toute diffusion, utilisation ou copie de ce message ou des renseignements qu'il contient par une personne autre que le (les) destinataire(s) d�sign�(s) est interdite.
Si vous recevez ce courrier �lectronique par erreur, veuillez m'en aviser imm�diatement, par retour de courrier �lectronique ou par un autre moyen.
...Re: Import access files to SAS
Dependent upon the structure of your access databases, the task could be
as simple as something like:
%do i=1 %to 128;
libname county&i. access "C:\temp\NY_county&i..mdb";
%do i=1 %to 128;
On Mon, 9 Jul 2007 17:18:47 -0400, Yufei Wang <yufeiw@GMAIL.COM> wrote:
>Is it same as importing multiple excel files to SAS?
>like Wenshui's blog shows:
>My problem is the files are not in the same director. The access file
>the attribute data for each county in each countie's directory, like this:
...Re: Importing data file that zipped
On Wed, 17 Sep 2003 22:14:40 +0800, mmxell <docdoc1357@TIPGOD.COM> wrote:
>Is it possible to read/import data file (in .txt or .mdb) that
Yes for sure! Uncompress/unzip it first, then import it...
...Re: error while importing file in sas
Have a look into your EXCEL file: is that true what SAS says?
Maybe you could try DDE, if you want to extract a certain area of that
file. Mark it in EXCEL and go in SAS to the menu pint "Solutions - Tools"
(could be other, I have only german SAS here and don't know how they
translated that). There you find something like "DDE Triplet". That you
can copy (CTRL-C) and paste it into a filename like
filename xx DDE "---here the triplet ----";
Then you can read the file with
input a b c;
On Mon, 18 Jun 2007 23:56:11 -0700, hipul <hipull@GMAIL.COM> wrote:
>While trying to import an excel file into sas, i get the following
>error: "Unable to sample external file-no records exist in the first 5
...Re: Import CSV file to SAS
The code in the reply below will not work for several reasons so I have
adjusted it a bit:
infile CARDS /* i just put the data here for convenience */
dlm=',' dsd missover;
informat ClientName $50. Protocol $ 8. shortname $ 8.;
input ClientName Protocol ShortName StatusID StudyID ;
ABC co ltd,ABC-3001,ABC3001,3,2314
DEF , D 123, D123, 4, 2256
There should not be commas in the input statement (This was the result, I
assume, of cutting and pasting)
The length followed the input statement but by that time, the SAS
supervisor had already set protocol and shortname to be numeric variables
since there was no other information. I changed this to an informat and
placed it before the input statement.
Now, in these 100 CSVs, are there always the same variables and are they in
the same order?
Environmental Specialist III
Dominion, Environmental Biology
4111 Castlewood Rd
Richmond, VA 23234
Phone:804-271-5313, Fax: 804-271-2977
Sent by: "SAS(r) SAS-L@LISTSERV.UGA.EDU
...Re: Import data from a text file
you are sure, that you want to create a table with ONE obs!?
Maybe the shortest way is to copy and paste it in a data-step, fill up
your desired variables and submit that (?)
If you want to make that dynamic, read the first two lines in a long char
variable and SCAN that out, what you want.
On Fri, 16 Jan 2009 11:45:06 +0100, yom <yomsas@GMAIL.COM> wrote:
>I would like to import data from a file so as to create a sas table.
>For example, I have a text file with N lines and three variables whose
>values are separated by a comma.
>I would like to create a sas table with one observation and four
>The first one is the first value of the second variable of the file : 1999
>The second one is the last value of the second variable of the file : 2003
>The third one is last value of the third variable of the file :
>The fourth one is all the second line : 25,1999,abdfvergc
>Thank you very much in advance.
...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: Empty SAS data file ...how
The following code may illustrate testing whether a datset is empty:
DATA Empty; STOP; RUN; * STOP prevents the only empty first record;
IF 0 THEN SET Empty NOBS=Nobs; * Never run, though compiled and determined;
CALL EXECUTE ('%LET Nobs = ' || PUT ( Nobs, BEST12. ) );
%PUT Nobs = &Nobs;
/* Within macro code:
%IF &Nobs EQ 0 %THEN %PUT Empty dataset;
Regards - Jim.
Y. (Jim) Groeneveld MSc
6825 MJ Arnhem
+31/0 26 376 7365; fax 7305
ww...Re: Importing SAS data into SPSS
Make a copy of the dataset and specify V8 (or earlier) as the engine in
the LIBNAME statement.
On Tue, 12 Oct 2004 16:36:48 -0400, Stephen Arthur <sdaemail@YAHOO.COM>
>I am trying to import a SAS data set (version SAS 9.1 TS Level 1M3) into
>SPSS (version 11.5.1 (16 Nov 2002)).
>I get the following SPSS error message:
>>Error # 7202. Command name: GET SAS
>>SAS dictionary read error.
>>This command not executed.
>Wrong Version -- SAS versions newer than 8 are not supported
>I only have SA...Re: How to filter sas data sets into separate sas data sets
a quick question first: what release of SAS are you using?
Seems like an ideal task for a hash solution. Hashes however are only available with SAS version 9.
Ansys AG, Zurich, Switzerland
> -----Ursprüngliche Nachricht-----
> Von: SAS(r) Discussion
> [mailto:SAS-L@LISTSERV.UGA.EDU]Im Auftrag von
> Lizette Koehler
> Gesendet: Montag, 2. April 2007 16:53
> An: SAS-L@LISTSERV.UGA.EDU
> Betreff: How to filter sas data sets into separate sas data sets
> This is my failing point in coding SAS. The use of 2
> separate SAS data sets to create a third.
> I can do this in a program with nested Do loops. But
> with SAS it is just different enough I seem to be
> unable to see the coding technique.
> Sas Data set 1 contains 1 variable and 1000 obs.
> Sas Data set 2 contains 15 variables and 500000 obs.
> I need to filter off the data in Sas data set 2 based
> on Sas data set 1
> Node1, Node2 and Node3 must match VAR1 exactly. I have
> all the code I need to do this except for splitting the
> data into a separate SAS data set (NEWLISTS).
> Psuedo code:
> Sas Data set 1: Var1 Length 7 Char
> Sas Data set 2: Node1 Length 1-8 Char Node2 Length
> 1-8 Char Node3 Length 1-8 Char
> Data Newlist (KEEP=node1 node2 node3 ... var15)
> Otherds (Keep=node1 node2 node3 .... var15) ;
...SPSS data file to SAS data file: only partial variable labels
Dear fellow SAS users:
I am trying to convert an SPSS data file (.sav, not .por) to SAS, using
SPSS version 15 for Windows. The data file is large, but not huge (176
cases, 963 variables). I have SAS 9.1.3 on Windows XP.
I used the following commands, and got the Warning message that "excess
labels will be omitted." (See below) SPSS successfully copied over the
variable labels for the first 2/3 of the variables, but then just stopped.
The wording of the message ("cumulative length of the variable labels
exceeds the limitations of the target file type") suggests that there is
some limitation of memory size involved.
Incidentally, I did succeed in getting the value labels captured in a
separate file containing SAS statements.
So the question is: Is there any way I can increase a default memory or
buffer size to allow SPSS to copy all the variable labels?
Thanks for any suggestions.
Here's my code and message:
get file = 'G:\q556\data\Master_file\master.sav'.
SAVE TRANSLATE OUTFILE='G:\q556\data\Master_file\master.sas7bdat'
/TYPE=SAS /VERSION=7 /PLATFORM=WINDOWS /MAP /REPLACE
>Warning # 9077
>The cumulative length of the variable labels exceeds the limitations of
the target file type. The excess labels will be omitted.
Data written to G:\q556\data\Master_file\master.sas7bdat.
963 variables and 176 cases written.
Variable: ID T...Import New Data File
I wonder if someone can help me with a small conundrum I am having.
This is what I want to achieve:
Each week, I import an excel spreadsheet called Week1.xls into an
access database. This table is then called Week1Data.
Already in the database is the table from the previous weeks import,
which is compared to the latest file, this file was called Week1Data
last week but is now called Week2Data.
There is a collection of past weeks imports in the database for
historic searching. This builds each week.
How do I rename last weeks Week1Data to make it Week2Data? ..and then
when I do another import next week, move Week2Data into an archive by
calling it Week3Data etc., So, my latest import will always be
Week1Data with the previous weeks Week1 now renamed Week2 with that
previous weeks Week2 now named Week3.
Thanks for any help!
You can rename the tables using the TableDefs collection of the Database
object in DAO. You will need a reference to the DAO object library, of
course. For example:
Dim tdf As TableDef
Dim db As Database
Set db = CurrentDb
Set tdf = db.TableDefs("Week2Data")
tdf.Name = "Week3Data"
Set tdf = db.TableDefs("Week1Data")
tdf.Name = "Week2Data"
Set db = Nothing
Set tdf = Nothing
You will need to consider the possibility that Week3Data already exists
before the ...Re: Re: how to import data???
Version 5 is much faster at Table Import.
On Sunday, September 21, 2003, at 04:42 AM, Bas Zoetekouw wrote:
> zulkefli wrote in comp.soft-sys.math.mathematica:
>> the data is
>> i save in C
>> what is the command to import this to mathematica
> Import["sample1.dat", Table] should do what you want. Note though,
> that is is extreemly slow for large data sets.
> Kind regards,
> Bas Zoetekouw ``Si l'on sait exactement ce que l'on va
> faire, a quoi bon le faire?''
> email@example.com Pablo Picasso
...Import collisions (was Re: "from module import data; print(data)")
On Thu, Feb 25, 2016 at 12:07 PM, Dan Stromberg <firstname.lastname@example.org> wrote:
> PS: Haskell seems better at the former than Python; Haskell tells you
> if you import two identical symbols from two different places, when
> you try to use one of them - not at import time. I believe in Python,
> whichever symbol you import last, wins. Haskell does not warn you at
> import time, which is fine. Not sure about OCaml or whatever else.
In a sense, it's not the two imports that matter, but the situation
that the second import statement is rebinding a name. Would it be
possible to create a "mollyguard" import hook that snoops the globals
of the importing module and raises an ImportWarning if it detects a
Not that I've ever been in the situation of wanting one, but just as a
point of intellectual curiosity.
...Re: How to filter sas data sets into separate sas data sets #6
First off, you don't need two set statements, I suspect you want a
(remember to sort datasets before merging)
Data newlist (KEEP=node1 node2 node3 ... var15)
Otherds (Keep=node1 node2 node3 .... var15) ;
Merge sasds1 sasds2;
By ;/*not sure which variable you need, but there has to be something
that is the same between the two*/
What I'd really need to know is what are the field names in DS1 and DS2
(You described them but didn't tell us the names)
You will possibly need a REANME= statement to get a matching name to
Either read up more on merges and RENAME or get back to us with the
variable names, and some sample data (maybe a proc print with obs=20).
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
Sent: Monday, April 02, 2007 9:53 AM
Subject: How to filter sas data sets into separate sas data sets
This is my failing point in coding SAS. The use of 2 separate SAS data
sets to create a third.
I can do this in a program with nested Do loops. But with SAS it is
just different enough I seem to be unable to see the coding technique.
Sas Data set 1 contains 1 variable and 1000 obs.
Sas Data set 2 contains 15 variables and 500000 obs.
I need to filter off the data in Sas data set 2 based on Sas data set 1
Node1, Node2 and Node3 must match VAR1 exactly. I have all the code I
need to do this except for splitting the...Re: How to filter sas data sets into separate sas data sets #8
On Mon, 2 Apr 2007 23:37:16 +0000, Ian Whitlock <iw1junk@COMCAST.NET> wrote:
>Summary: You need a loop and the POINT option or SQL
>I think a lot of respondents have misunderstood the problem. This probably
>could have been avoided with a simplified example. Here is my
>interpretation. Here is code to generate data.
> data control ;
> do var1 = 1 to 4 ; output ; end ;
> run ;
> data tosplit ;
> input node1 node2 node3 other ;
> cards ;
> 1 2 3 4
> 1 2 3 5
> 7 7 7 7
Here are test data generators which conform to the actual scale of the problem.
do _n_ = 1 to 1000;
var1 = floor(ranuni(135)* 100000);
do other = 1 to 500000;
node1 = floor(ranuni(246)* 100000);
node2 = floor(ranuni(246)* 100000);
node3 = floor(ranuni(246)* 100000);
>Here is a way to split using the DATA step.
> data newlist other ;
> drop flag var1 ;
> set tosplit ;
> do pt = 1 to nobs ;
> set control point = pt nobs = nobs ;
> if var1 = node1 or var1 = node2 or var1 = node3 then
> flag = 1 ;
> end ;
> if flag then output newlist ;
> output other ;
> run ;
At full scale the loop runs one half billion times. That took about 9
minutes on my PC....Re: How to filter sas data sets into separate sas data sets #7
Summary: You need a loop and the POINT option or SQL
I think a lot of respondents have misunderstood the problem. This probably
could have been avoided with a simplified example. Here is my
interpretation. Here is code to generate data.
data control ;
do var1 = 1 to 4 ; output ; end ;
data tosplit ;
input node1 node2 node3 other ;
1 2 3 4
1 2 3 5
7 7 7 7
Here is a way to split using the DATA step.
data newlist other ;
drop flag var1 ;
set tosplit ;
do pt = 1 to nobs ;
set control point = pt nobs = nobs ;
if var1 = node1 or var1 = node2 or var1 = node3 then
flag = 1 ;
if flag then output newlist ;
output other ;
And here is a way to split using SQL.
proc sql ;
create table newlist as
select * from tosplit
where node1 in (select var1 from control)
or node2 in (select var1 from control)
or node2 in (select var1 from control)
create table other as
select * from tosplit
where not(node1 in (select var1 from control)
or node2 in (select var1 from control)
or node2 in (select var1 from control))
Date: Mon, 2 Apr 2007 10:53:08 -0400
Sender: "SAS(r) Discussion"
From: Lizette Koehler <starsoul@MINDSPRING.COM>...Re: How to filter sas data sets into separate sas data sets #3
Instead of trying to merge the two data sets, I would probably try to create
a SAS format from the values of VAR1 in data set 1. Then, NODE1, NODE2 and
NODE3 could be compared against the format for a match.
The example below is a simplified version of what you could do and shows a
printout of how it works. It has 5 observations in data set 1 and only 3
variables in data set 2, but I think the logic should hold for the example
you gave. After the example is code that could be used to actually split
the data as you had requested. Hope this helps.
* create sas data set 1 ;
input var1 $;
* sort data set 1 to eliminate any duplicate values ;
proc sort nodupkey data = sasds1 out = sasds1_dd (rename=(var1=start));
* create data set that will be used to build SAS format ;
set sasds1_dd end=last;
fmtname = '$NODES';
label = 'Y';
if last then do;
* build format (the optional fmtlib option will print the format for you to
proc format cntlin = sasds1_dd fmtlib;
* create sas dataset 2 ;
input node1 $ node2 $ node3 $;
ZZZ YYY XXX
AAA YYY XXX
ZZZ FFF XXX
ZZZ YYY DDD
AA YYY XXX
ZZZ AAAA XXX
* apply format to node1-node3 to determine if there is a match ;
if put(node1,$nodes.) = 'Y' or
put(node2,$nodes.) = '...