BookmarkSubscribeRSS Feed
gtucke1
Fluorite | Level 6

Hi,

 

I'm doing a secondary data analysis using a dataset with data collected by someone else.

I made a copy of the data set. I exported the dataset to make correct variables that were in as character and should have been numeric. However, when I import the data set with changes, the changes are not there. I think it might be an issue with my import statement and "replace" not being in blue. Below is my code.

 

Proc export data = ICPNEED.cg_demo_fix
Outfile = 'C:\Users\gtuck\OneDrive\Documents\Gretchen Dissertation\SAS\Working Data Set\cg_demo_fix.xlsx'
DBMS = XLSX replace;
Sheet = 'cg_demo_fix';
Run;

Proc import datafile = 'C:\Users\gtuck\OneDrive\Documents\Gretchen Dissertation\SAS\Working Data Set\cg_demo_fix.xlsx'
OUT = ICPNEED.cg_demo_fix
DBMS = XLSX Replace;
Sheet = 'cg_demo_fix';
Run;

/*Have to fix cg_edu, iadl_income_1 and iadl_income_2 from character to numeric*/
/*Proc export data = ICPNEED.cg_demo_fix
Outfile = 'C:\Users\gtuck\OneDrive\Documents\Gretchen Dissertation\SAS\Working Data Set\cg_demo_corrected.xlsx'
DBMS = XLSX replace;
Sheet = 'cg_demo_corrected';
Run;

 

 

 

1 REPLY 1
ballardw
Super User

Since XLSX files will pick whether variables are numeric or character based on internal rules I suspect that whole approach. Or why the export was even desirable in the first place. It was likely easier to use SAS code with an INPUT function to convert the variable type.

 

What does the LOG show. There should be a message that the data set was not replaced similar to this if the Replace option was not honored:

NOTE: Import cancelled.  Output dataset WORK.JUNK already exists.  Specify REPLACE option to
      overwrite it.

 

And almost certainly should not tried to replace the initial dataset at all. The correct approach would be read it into a new data set and the use Proc Compare to see what the differences are between the old and new data set.

 

 

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
  • 1 reply
  • 456 views
  • 0 likes
  • 2 in conversation