BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
kmohajerin
Fluorite | Level 6

I am a very new user struggling to access a LST file. I have to use the data within the file to run data and proc steps for analysis, but I've been unable to access/convert/import the file into Enterprise Guide. 

 

This is a sample row of the data file pasted directly from Enterprise Guide. I was unable to attach the lst file to this post. 

 

9 2 38 0 0 0 0 0 1 2 3 0 999999.99 999999.99 0 0 1 0 0 3 2 20100309 0 2 2 20100630 3 2

 

Can you access raw LST data using Enterprise or SAS Access? Thank you in advance!

 

Kevin

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

@kmohajerin wrote:

Sorry for the ambiguity, this is the entire situation, which I now realize is somewhat hopeless.

 

I have a .lst file (SAS text output) that was produced by a different user. This file is atrocious, with no clear formatting, simply rows of numerical data. The column titles were sent as a separate email. What I am trying to do is to import/reconfigure/something this data into a SAS program so that I can run various procedures on it. 

One major issue is: I don't understand why this data is even in this format. My question was based on my false assumption that a .lst file, like Excel files and CSV files, could be imported using SAS Access or a simple data step. These columns are basic information like Gender, Age, Veteran Status, Income, etc. 

 

I will contact the counterpart that created this .LST file and see if he can get this data into a more accessible format. 

 

 

 


I agree that getting the creator to provide the, apparently summarized data, as a data step would be preferred. You might find in the long run that having access to the raw data would be better in the long run. I understand that may be against policy but should be investigated. Perhaps data with certain fields such as personally identifiable information removed. One reason is that summaries without knowing exactly how they were built may well disguise the things you are looking for. Plus when you have possibly only the results for Gender, Age as separate summaries then getting Gender and Age combinations when needed is impossible. Or other more complex combinations of the demographics.

 

I will not say that it is impossible but the fact that someone stripped off the column labels (to put in an email ?!) makes it harder to align the columns and row values.

 

I have read such summary files, think columns as calendar month, row as day of the month with a grid of values and a separate page for values like temperature max or min, relative humidity , for each recording site and calendar year. But it involves lots of data step coding and understanding how to parse values.

View solution in original post

8 REPLIES 8
ballardw
Super User

LST files in SAS generally refer to text output generated by SAS. Is this the case for your project?

If so, such LST files would be text and you will likely need to write Data Step code to read them as they are generally not going to be a "nice" format for reading into a data set.

 

 

I would say that the process generating the LST file should be also be creating data sets if they are needed. Even the pretty obnoxious tables created by some procedures can usually be directed to an output data set using the ODS OUTPUT options.

 

One example of creating output data sets for the results tables of a procedure:

ods output onewayfreqs=work.freq;
ods output onewaychisq =work.chi;
proc freq data=sashelp.class;
   tables sex age/chisq;
run;

The data set work.freq would have a variable indicating which table, sex or age, the value levels and count, cumulative count, percent and cumulative percent for each variable. The Work.Chi would again have a table indicator, statistic name, label and statistic values.

kmohajerin
Fluorite | Level 6

Yes, I requested mostly demographic data and the last thing I expected was pure SAS text output. I was hoping there was a simple data step that could convert this into something usable. I guess using ODS OUTPUT and creating my own table is the only solution? 

 

 

 

ballardw
Super User

@kmohajerin wrote:

Yes, I requested mostly demographic data and the last thing I expected was pure SAS text output. I was hoping there was a simple data step that could convert this into something usable. I guess using ODS OUTPUT and creating my own table is the only solution? 

 

 

 


Can't say actually. Your description is pretty vague. A large number of SAS procedures have specific options for creating data sets containing the output.

You can create output data sets for each table request from proc freq without creating any list (or ods) output:

proc freq data=sashelp.class;
   tables sex /out=work.freqsex    ;
   tables age /out=work.freqage;
   tables sex*age/out=work.freqsexage;
run;

Note these output tables have different contents and structure than the ODS output example. And the only output is the count and percent, you can request the cumulative numbers as well with other options. But the CHISQ output won't go to the output data set if you add that option.

 

So it really depends on what you are actually doing what may be a 'best' approach. Since you said you were attempting to read an LST I have to assume you were attempting to create a data set. If that is not the case then you need to provide a more concrete example.

kmohajerin
Fluorite | Level 6

Sorry for the ambiguity, this is the entire situation, which I now realize is somewhat hopeless.

 

I have a .lst file (SAS text output) that was produced by a different user. This file is atrocious, with no clear formatting, simply rows of numerical data. The column titles were sent as a separate email. What I am trying to do is to import/reconfigure/something this data into a SAS program so that I can run various procedures on it. 

One major issue is: I don't understand why this data is even in this format. My question was based on my false assumption that a .lst file, like Excel files and CSV files, could be imported using SAS Access or a simple data step. These columns are basic information like Gender, Age, Veteran Status, Income, etc. 

 

I will contact the counterpart that created this .LST file and see if he can get this data into a more accessible format. 

 

 

 

Tom
Super User Tom
Super User

Why not just ask to have the actual SAS dataset sent to you?

The problem with CSV files is they have no way to store the metadata about the variables. Is that column a number or is it character string that just happens to only contain digits?

The problem with EXCEL files is that hey have no concept of a variable.  Each cell is independent.

kmohajerin
Fluorite | Level 6
This is actually good validation for me as a new user. I was ripping my face off wondering what I was doing wrong, and this forum validated my fears.

I will ask for the raw SAS dataset, but any formatted data would be better than the monstrosity that is this LST file. Thank you so much for your support everybody!
ballardw
Super User

Just for giggles would it be possible to either copy a few lines, 10 to 20 or so, of the LST file, copy using a plain text editor, and paste onto the forum into a code box opened with the {I} icon? The code box is important because the message windows will reformat text.

And include that "header information" in another code box.

 

Unless it is really egregious we may be able to show the type of code that is needed to read it.

 

ballardw
Super User

@kmohajerin wrote:

Sorry for the ambiguity, this is the entire situation, which I now realize is somewhat hopeless.

 

I have a .lst file (SAS text output) that was produced by a different user. This file is atrocious, with no clear formatting, simply rows of numerical data. The column titles were sent as a separate email. What I am trying to do is to import/reconfigure/something this data into a SAS program so that I can run various procedures on it. 

One major issue is: I don't understand why this data is even in this format. My question was based on my false assumption that a .lst file, like Excel files and CSV files, could be imported using SAS Access or a simple data step. These columns are basic information like Gender, Age, Veteran Status, Income, etc. 

 

I will contact the counterpart that created this .LST file and see if he can get this data into a more accessible format. 

 

 

 


I agree that getting the creator to provide the, apparently summarized data, as a data step would be preferred. You might find in the long run that having access to the raw data would be better in the long run. I understand that may be against policy but should be investigated. Perhaps data with certain fields such as personally identifiable information removed. One reason is that summaries without knowing exactly how they were built may well disguise the things you are looking for. Plus when you have possibly only the results for Gender, Age as separate summaries then getting Gender and Age combinations when needed is impossible. Or other more complex combinations of the demographics.

 

I will not say that it is impossible but the fact that someone stripped off the column labels (to put in an email ?!) makes it harder to align the columns and row values.

 

I have read such summary files, think columns as calendar month, row as day of the month with a grid of values and a separate page for values like temperature max or min, relative humidity , for each recording site and calendar year. But it involves lots of data step coding and understanding how to parse values.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 8 replies
  • 5083 views
  • 2 likes
  • 3 in conversation