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

Vani1493_0-1671121274882.png

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

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.

--
Paige Miller

View solution in original post

7 REPLIES 7
PaigeMiller
Diamond | Level 26

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.

--
Paige Miller
Vani1493
Fluorite | Level 6

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

 

PaigeMiller
Diamond | Level 26

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.

--
Paige Miller
Vani1493
Fluorite | Level 6

thank you so much...got it now...variable name changed...😀

ballardw
Super User

@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.

Tom
Super User Tom
Super User

@Vani1493 wrote:

Vani1493_0-1671121274882.png

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;
Vani1493
Fluorite | Level 6

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.

 

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 7 replies
  • 565 views
  • 1 like
  • 4 in conversation