Can anyone help how to do proc freq for the Mat variable from the above Excel..
proc freq data= dataset name;
table Mat;
run;
Log showing Mat variable is not there in this dataset
I pointed out the next step. I said:
"You need to look in the corresponding SAS data set and see for yourself what variable names are in there."
Please do that. I also explained that sometimes when you convert an Excel file to SAS, the variable names change.
You need to look in the corresponding SAS data set and see for yourself what variable names are in there. More than likely, the process of converting Excel to SAS has changed the variable names.
I converted it to the SAS dataset. I can do proc freq for heading Maternal_Data, but why cannot we do proc freq for the below variable (the main heading is Maternal_Data and subheadings are No, SN, MA etc.).
proc freq data=dataset name;
table F;
run;
the above is working.
proc freq data=dataset name;
table Mat;
run;
The above is not working
Why...please help me
I pointed out the next step. I said:
"You need to look in the corresponding SAS data set and see for yourself what variable names are in there."
Please do that. I also explained that sometimes when you convert an Excel file to SAS, the variable names change.
thank you so much...got it now...variable name changed...😀
@Vani1493 wrote:
thank you so much...got it now...variable name changed...😀
Expected such. You did not say how you read the data into SAS but I would suspect use of either Proc Import or a tool that calls that procedure. Proc Import will attempt to use the first row of values for variables. Your picture showed two rows with several under a spanning header. So likely you have a bunch of Var1, Var2 variables because the first row for many cells did not have any text. Also since the first "values" seen in most of those columns was what you are thinking of as headers that the values were all treated as text even if most of the column should be numeric.
Spreadsheets are messy at best. Often it is better to save the file as CSV. Then there are more tools that will work with reading the file such as writing a data step that allows you to specify which row data actually starts on and what names you want for the variables.
@Vani1493 wrote:
Can anyone help how to do proc freq for the Mat variable from the above Excel..
proc freq data= dataset name;
table Mat;
run;
Log showing Mat variable is not there in this dataset
That sheet is not designed to be used as data. It has extraneous stuff ("Meternal Data") before the actual data table.
If you cannot fix the sheet to look like data you might try telling PROC IMPORT to skip the first row by setting A2 is the upper left corner of the range.
proc import dbms=xlsx file='myfile.xlsx' out=want replace;
range='$A2:';
run;
Thank you Tom for your solution...I will try whatever you suggest with range option.
I know I am asking silly doubts here 😥, but I am a new learner of SAS. I am really happy that I am getting support here.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.