BookmarkSubscribeRSS Feed
shellp55
Quartz | Level 8

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.

3 REPLIES 3
Tom
Super User Tom
Super User

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

;

shellp55
Quartz | Level 8

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.

Tom
Super User Tom
Super User

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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 812 views
  • 0 likes
  • 2 in conversation