1
   

SAS Help

 
 
terryvu
 
Reply Thu 3 Feb, 2005 11:35 pm
I am a newbie in using SAS. Actually I am studying it. I have got a question for 2 days and I don't know how to solve it.

Problem:
I created a dataset file named "abcd.sas7bdat" which contains about 5 numeric variables (ie: a, b, c, d, e). What I want is that I would like to take 2 variables and the subtract them together and assign to a new variable (eg: x = a - c).
I started SAS program and then use " infile " statement to call it, then

=======================
DATA temp;
INFILE 'C:\SAS\abcd.sas7bdat';
INPUT a c;
x = a - c;
RUN;
=======================

There are a lot error in reading this code. WOuld you please show me how to get what I really want.......

Thank you so much for your help,
Terry Vu
  • Topic Stats
  • Top Replies
  • Link to this Topic
Type: Discussion • Score: 1 • Views: 815 • Replies: 5
No top replies

 
Vengoropatubus
 
  1  
Reply Fri 4 Feb, 2005 03:31 pm
SAS being Side-Angle-Side congruence theorem or am I just completely confused?
0 Replies
 
engineer
 
  1  
Reply Fri 4 Feb, 2005 03:38 pm
No Software
SAS is a statistical software package. I haven't written SAS in at least five years. What is the error you are getting? If the INPUT statement fails, all of the others will also.
0 Replies
 
terryvu
 
  1  
Reply Fri 4 Feb, 2005 06:11 pm
problem explanation
Thank you so much for your replies.

What I really want to do is: Read a file which contains data and do a very simple mathematic calculation ie: subtraction.

What I did:

1. After working around with SAS, I can read a file now (ie: sample.dat, sample.txt but not sample.sas7bdat) by INFILE statement and then do mathematic / statistic calculation.

However, IF data stored in " sample.dat " having " TAB " then there will be error saying SAS cannot read and CHAR ......xyz.......NUM...... . This problem could be fixed by changing a TAB by series of space using space bar.

My question for this problem is: IF data stored in sample.dat having TABs, how can we read the data?

=======ooo00ooo========

2. About sample.sas7bdat file. I still cannot read this kind of SAS file once it has been created using INFILE statement and do mathematic work with it.

My question for this problem is: How to read file which ends up with "sas7bdat" ie: sample.sas7bdat ?

I greatly appreciate your help. Hope to have your answer soon.

Have a nice day,
Terry Vu
0 Replies
 
Ex Pat
 
  1  
Reply Fri 11 Feb, 2005 03:41 pm
SAS Help
1. To read sample.dat containing TAB characters, just add EXPANDTABS to the INFILE statement
ie INFILE 'C:\SAS\sample.dat' EXPANDTABS;

2. You have already created a permanent SAS dataset called abcd so you don't need to read it in again. If you look in C:\SAS you will find it called abcd.sas7bdat
So if you want to add a new variable, you just have to make sure you have a LIBNAME pointing to the directory then create a new dataset or overwrite the first one, eg
LIBNAME L 'C:\SAS';
DATA L.ABCD;
SET L.ABCD;
X=A-C;
RUN;
0 Replies
 
terryvu
 
  1  
Reply Fri 11 Feb, 2005 03:50 pm
wow....It is so clear Ex_Pat. I got it now. Thank you so much for your help.

Have a nice day,
Terry Vu
0 Replies
 
 

Related Topics

Evolution 101 - Discussion by gungasnake
Typing Equations on a PC - Discussion by Brandon9000
The Future of Artificial Intelligence - Discussion by Brandon9000
The well known Mind vs Brain. - Discussion by crayon851
Scientists Offer Proof of 'Dark Matter' - Discussion by oralloy
Blue Saturn - Discussion by oralloy
Bald Eagle-DDT Myth Still Flying High - Discussion by gungasnake
DDT: A Weapon of Mass Survival - Discussion by gungasnake
 
  1. Forums
  2. » SAS Help
Copyright © 2024 MadLab, LLC :: Terms of Service :: Privacy Policy :: Page generated in 0.03 seconds on 05/18/2024 at 09:39:05