01-24-2017 08:39 PM - edited 01-24-2017 09:14 PM
I have a variable that is named Units. Some of the values the variable takes on are:
x10E3/uL ---------> /* means "times 10000/uL" It is in E notation here. */
As you can see there is a mix of letters and numbers as well as slashes in the 2 observations. How can I tell SAS to read the entire string from a raw data file?
I also have another variable named Interval with values such as:
3.4 - 10.8
4.14 - 5.80
How can I read these from a raw data file as well?
01-24-2017 09:22 PM
01-24-2017 10:44 PM
You tell SAS to use a specific delimiter or to read for a specific length.
Given what you've posted we can't really suggest solutions beyond this. Reading a text file can be complicated or easy, it depends on multiple factors and we only have a minimal idea of your issue.
If you'd like further help please post sample data that accurately reflects your situation.
01-25-2017 01:14 AM - edited 01-25-2017 01:16 AM
The only difficulty is the dash between the range values. Use pointer control (here +1) to skip it.
data abc; length units $12; input id rangeLow +1 rangeHigh units :$12.; datalines; 1 3.4 - 10.8 x10E3/uL 100 4.14 - 5.80 mL/min/1.73 ; proc print; run;
01-25-2017 03:44 AM
To acces the input buffer (whole line of the file) use the automatic variable _INFILE_
data WANT; infile "<myfile>" lrecl=200; input; put _INFILE_; run;
You can also check the following paper by Howard Schreier: http://www.lexjansen.com/nesug/nesug01/cc/cc4018bw.pdf
Daniel Santos @ www.cgd.pt
01-25-2017 10:13 AM
What type of file are you reading from? Most delimited files such as CSV should handle this easily though unmatched quotes might cause other problems. Fixed column has no problem as long as the correct variable type is assigned.