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. */
mL/min/1.73
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?
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.
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;
Hi.
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
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.
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!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.