Hello
I am trying to import a .txt file where the data is "long" and I want to convert it to "wide" where one line of data is one record.
An example of one record of the raw data would be:
SHEPE
00001
89582
E12345
7/1/2012 10:24:05 AM
1
03
What I want it to look like:
SHEPE0000189582E123457/1/2012 10:24:05 AM103
Field description:
DocName = text
DocService = text
Chartno = text
Acctno = text
visit date/time = date/time
triage level = text
disposition code =text
Thanks for any assistance.
It sounds like you want to convert one form of raw data into another. Why?
I would suggest just reading it into SAS in its current form. Once you have read it you can write it out again in any form you want.
data want ;
input
DocName $30.
/ DocService $30.
/ Chartno $10.
/ Acctno $10.
/ VisitDT anydtdtm.
/ Triage $1.
/ Disposition $2.
;
format visitdt datetime20. ;
cards;
SHEPE
00001
89582
E12345
7/1/2012 10:24:05 AM
1
03
;
HI
Sorry but your program copied and used as is into SAS doesn't work. It shows the data on two lines and blanks in some of the sections.
I want to convert the format of the raw data to better manipulate it for my needs i.e. linking to another table that is in the wide format.
Any assistance would be greatly appreciated. Thanks.
The program runs fine. Your actual data is probably more complex so you will need to adjust it to match your data.
It creates a dataset with multiple variables which is what it sounds like you need.
1 data want ;
2 input
3 DocName $30.
4 / DocService $30.
5 / Chartno $10.
6 / Acctno $10.
7 / VisitDT anydtdtm.
8 / Triage $1.
9 / Disposition $2.
10 ;
11 format visitdt datetime20. ;
12 cards;
NOTE: The data set WORK.WANT has 1 observations and 7 variables.
NOTE: DATA statement used (Total process time):
real time 0.09 seconds
cpu time 0.05 seconds
20 ;
21 data _null_;
22 set;
23 put (_all_) (=/);
24 run;
DocName=SHEPE
DocService=00001
Chartno=89582
Acctno=E12345
VisitDT=01JUL2012:10:24:05
Triage=1
Disposition=03
NOTE: There were 1 observations read from the data set WORK.WANT.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.