Hi Team,
I am new in sas, In attached file how to import the data in sas such that only transaction data is imported and only header data is imprted.
Kindly advise.
Thanks,
Manoj Ahuja
Please post your expected output
@Manojahuja1418 wrote:
Hi Team,
I am new in sas, In attached file how to import the data in sas such that only transaction data is imported and only header data is imprted.
Kindly advise.
Thanks,
Manoj Ahuja
Simple text can be posted using the forum's {I} icon as such so it is available to read easily:
H 1095 NJ 06DEC84 C 01DEC11 $45.0 C 01AUG11 $37.5 H 1096 CA 01SEP83 C 01JUL11 $156.7 H 1097 VG 07JUL74 C 01FEB11 $109.5 H 1099 OT 13FEB79 C 01Mar11 $45.0 C 01May11 $45.0 H 1202 CA 01JAN81 C 01May11 $37.0 C 01Oct11 $45.0 C 01Feb11 $109.5 H 1090 PT 01DEC11 C 01MAR11 $45.0 C 01MAY11 $45.0 H 1267 OH 03DEC59 C 01May11 $37.0 C 01OCT11 $45.0 C 01FEB11 $109.5 H 1001 NJ 05OCT62 C 01MAR11 $45.0 C 01MAY11 $45.0 H 1299 FL 16SEP84 C 01MAY11 $37.0 C 01OCT11 $45.0
How do we tell what is "transaction data" and "header" (I can guess but guessing is a poor way to write code)?
Do you want one data set that holds transaction data and another with header data?
You should provide an example, likely only 2 or 3 records of what you expect the result to look like. You should indicate what variable names are desired, whether the value is numeric or character and what the maximum length is expected for any character value.
Your data shows two possible variables holding date values. If those dates indicate different things then they should have different names so you know which is which.
A data step can conditionally read values and retain information from previous records.
To do thing conditionally use an IF statement.
If you want one data step to generate two datasets lists them both in the DATA statement. You can use dataset options to control which variables are kept in each dataset.
Here is an sketch of a program. Fill in the details based on what it actually in you text file.
data h(keep=type a b c ) c(keep=type x y z);
infile 'myfile.txt' truncover;
input type $ @;
if type ='H' then do;
input a b c ;
output h;
end;
else do;
input x y z ;
output c;
end;
run;
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.