Hi. I need to generate frequencies of specific variables (TEM and DHA) which has alphanumeric values
TEM has: TEM, TEM-1, TEM-1(b), TEM-10, TEM-10(e)
DHA has: NEG, DHA-1, DHA-15,DHA-TYPE,DHA
Proc freq data=AMR;
Tables TEM DHA;
run;
The SAS codes showed only the following.
it appears it did not read the alphanumeric values.Kindly suggest what needs to be done. Thanks
I imported the data (in csv) with this code
proc import datafile = "....csv"
out = Add
dbms = csv
replace;
run;
I added "guessingrows=max" but it gave this response
There is unending running of string variables in the log
I changed to "guessingrows=15, but the frequencies omitted the alphanumeric variables still. Kindly suggest a way forward. Thank you.
The Log window full means that something about the file is generating lots of text. The most likely cause is something related to invalid data.
Question: did you ever open this CSV file in spreadsheet software? Did you SAVE it after opening with spreadsheet software? If the answer to both of these questions is YES then your file may have had the values changed by the spreadsheet and could be quite unreliable.
If the answer is know then open the CSV file in some text editing program like Notepad, copy the first 10 rows, then on the forum open a text box using the </> and paste the text. The text box is important to keep the forum from reformatting white space in text.
From what your picture shows I have feeling that your data file has many problems. Possibly related to line lengths and misaligned columns. I have a hard time believing that a column that would have value like "65-84 years" also has "<-0.06". That typically would indicate that a column, if the file is actually CSV, has 2 or more different types of values and that is not normal for a proper CSV file.
When you set Guessingrows to 15 that is even fewer rows than the default.
NEVER use PROC IMPORT for csv files. You'll spend more time fixing stuff caused by the guessing than you need to write the DATA step yourself.
Thanks. Writing the datastep as shown below does not help either.
%let path=C:\...;
options validvarname=v7;
proc import datafile="&path\....csv"
out=add
dbms=csv replace;
guessingrows=max;
run;
The code you posted is not a data step, that's still proc import. A data step would look something like this:
data add;
infile "&path\...csv" dsd truncover;
informat var1 $8. var2 8. var3 8. var4 $12.;
input var1 var2 var3 var4;
run;
Here's a short tutorial on how to do so, and as mentioned previously PROC IMPORT puts the code it uses in the log. You can copy it and modify the type/format as needed for your data.
http://eta.health.usf.edu/publichealth/PHC6701/presentations/2013/readingExternalFilesSAS.pdf
@femiajumobi1 wrote:
Thanks. Writing the datastep as shown below does not help either.
%let path=C:\...;
options validvarname=v7;proc import datafile="&path\....csv"
out=add
dbms=csv replace;
guessingrows=max;
run;
@femiajumobi1 wrote:
Thanks. Writing the datastep as shown below does not help either.
%let path=C:\...;
options validvarname=v7;proc import datafile="&path\....csv"
out=add
dbms=csv replace;
guessingrows=max;
run;
This is NOT a DATA step.
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
For SAS newbies, this video is a great way to get started. James Harroun walks through the process using SAS Studio for SAS OnDemand for Academics, but the same steps apply to any analytics project.
Find more tutorials on the SAS Users YouTube channel.