- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 08-29-2010 01:20 PM
(3397 views)
Hello All,
I have got a dataset which is in a text file and has around 400 variables and more than 10,000 records. I want to import this file in SAS and I will be using Infile for importing the dataset. But for using Infile we need to define the variable names in the dataset which in my case is not defined.
Now as there are around 400 variables is there any easy way of defining the variables in the Infile format ?
(Plz guide me if I have posted this question in a wrong section)
Waiting for the reply.
Thanks! Message was edited by: Pritish
I have got a dataset which is in a text file and has around 400 variables and more than 10,000 records. I want to import this file in SAS and I will be using Infile for importing the dataset. But for using Infile we need to define the variable names in the dataset which in my case is not defined.
Now as there are around 400 variables is there any easy way of defining the variables in the Infile format ?
(Plz guide me if I have posted this question in a wrong section)
Waiting for the reply.
Thanks! Message was edited by: Pritish
5 REPLIES 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Given your post, it's unclear how you would expect to associate variable names, other than having the information either in the input-data file (typically as the first/header row) or by using logic in your SAS DATA step (you mentioned INFILE) program code-piece?
Suggest you share a simplified data-sample (raw input) and also share what you expect to see (SAS dataset/member/table result) as the outcome from your INFILE processing?
Scott Barry
SBBWorks, Inc.
Suggested Google advanced search arguments, this topic / post:
intro data step programming site:sas.com
proc import site:sas.com
input data step site:sas.com
Suggest you share a simplified data-sample (raw input) and also share what you expect to see (SAS dataset/member/table result) as the outcome from your INFILE processing?
Scott Barry
SBBWorks, Inc.
Suggested Google advanced search arguments, this topic / post:
intro data step programming site:sas.com
proc import site:sas.com
input data step site:sas.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Scott,
Thanks for the reply. Here is a sample raw input which you are looking for:
0.2,0.5,31,46,57,9.4,7.5
1.3,2.3,20,55,91,4.3,3.0
I have comma separated value in my txt file. I have in all around 400 variable with a similar values. So what I am trying to do is to import the dataset in SAS using Infile statement. Now the format for infile statement is like
DATA WORK.dataset.name;
INFILE "Path.txt" DELIMITER=','x;
INPUT var1 var2 var3;
RUN;
I want my dataset in SAS to be like:
Var1 Var2 Var3 Var4 ..... Varn
0.2 0.5 31 46 ....
1.3 2.3 20 55
It's not feasible to write all 400 variable name in the Input step right ?
So can you suggest me a better way for this ?
Thanks for the help.
Thanks for the reply. Here is a sample raw input which you are looking for:
0.2,0.5,31,46,57,9.4,7.5
1.3,2.3,20,55,91,4.3,3.0
I have comma separated value in my txt file. I have in all around 400 variable with a similar values. So what I am trying to do is to import the dataset in SAS using Infile statement. Now the format for infile statement is like
DATA WORK.dataset.name;
INFILE "Path.txt" DELIMITER=','x;
INPUT var1 var2 var3;
RUN;
I want my dataset in SAS to be like:
Var1 Var2 Var3 Var4 ..... Varn
0.2 0.5 31 46 ....
1.3 2.3 20 55
It's not feasible to write all 400 variable name in the Input step right ?
So can you suggest me a better way for this ?
Thanks for the help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Why don't you try proc import? E.g.,:
PROC IMPORT OUT= WORK.WANT
DATAFILE= "c:\path.txt"
DBMS=DLM REPLACE;
DELIMITER='2C'x;
GETNAMES=NO;
DATAROW=1;
RUN;
HTH,
Art
PROC IMPORT OUT= WORK.WANT
DATAFILE= "c:\path.txt"
DBMS=DLM REPLACE;
DELIMITER='2C'x;
GETNAMES=NO;
DATAROW=1;
RUN;
HTH,
Art
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Art,
Thanks for the reply. It really worked.
Thanks for the help !
Thanks for the reply. It really worked.
Thanks for the help !
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
> Hello All,
>
> I have got a dataset which is in a text file and has
> around 400 variables and more than 10,000 records. I
> want to import this file in SAS and I will be using
> Infile for importing the dataset. But for using
> Infile we need to define the variable names in the
> dataset which in my case is not defined.
>
> Now as there are around 400 variables is there any
> easy way of defining the variables in the Infile
> format ?
>
> (Plz guide me if I have posted this question in a
> wrong section)
>
> Waiting for the reply.
>
> Thanks!
>
> Message was edited by: Pritish
data output_dataset ;
infile 'where.ever' dsd ......... what ever options needed like lrecl= and firstobs= ;
length var1-var400 8 ;
input var1-var400 ;
run ;
if var25 is string length 10, then your code might change only at
length var1-var24 8 var25 $10 var25-var400 8 ;
>
> I have got a dataset which is in a text file and has
> around 400 variables and more than 10,000 records. I
> want to import this file in SAS and I will be using
> Infile for importing the dataset. But for using
> Infile we need to define the variable names in the
> dataset which in my case is not defined.
>
> Now as there are around 400 variables is there any
> easy way of defining the variables in the Infile
> format ?
>
> (Plz guide me if I have posted this question in a
> wrong section)
>
> Waiting for the reply.
>
> Thanks!
>
> Message was edited by: Pritish
data output_dataset ;
infile 'where.ever' dsd ......... what ever options needed like lrecl= and firstobs= ;
length var1-var400 8 ;
input var1-var400 ;
run ;
if var25 is string length 10, then your code might change only at
length var1-var24 8 var25 $10 var25-var400 8 ;