@ashish112: Add the statement
guessingrows=max;
to the PROC IMPORT step for data2.csv to avoid this truncation.
In addition, you will need the REPLACE option of the PROC IMPORT statement.
I have tried this still same error comes, see the attached log
I am still working on solution, no success yet. My major concern is the error comes when there is extra variables in data2 file which are not in data1 file.
Is there any other solution?
Look, we cannot guess what is happening your end. Please post test data - which gives actual examples of what you are working with - for both datasets, in the form of a datastep. Then show the code you are running. Then show the log that it is created. The code I presented above works fine given the parameters know by me - that person not sitting at your desk looking at your work:
proc sql noprint; select cats(oldname,'=',newname) into :renames separated by ' ' from import1 where upcase(oldname) in (select name from sashelp.vcolumn where libname="WORK" and memname="IMPORT2"); quit; proc datasets library= work nolist; modify import; rename &renames; run; quit;
@FreelanceReinh wrote:
@ashish112: Add the statement
guessingrows=max;
to the PROC IMPORT step for data2.csv to avoid this truncation.
In addition, you will need the REPLACE option of the PROC IMPORT statement.
You forgot the GUESSINGROWS statement.
I was about to post the following PROC SQL step when I saw RW9's earlier post using an equivalent technique (sashelp.vcolumn rather than dictionary.columns😞
proc sql noprint;
select cats(old_name,'=',new_name) into :renames separated by ' ' from
(select * from _names_ a, dictionary.columns b
where b.libname='WORK' & b.memname='DATA1' & a.old_name=b.name);
quit;
(where _names_ and DATA1 are the datasets created from your original Data2.csv and Data1.csv files via PROC IMPORT; note the underscores in the variable names).
Hi , thanks for the suggestion.
I tried this but error comes at line: rename &renames;
I have attached the log here, can you please look in to this? sorry for late reply.
Hi @ashish112,
Don't make the same mistakes twice:
oh yes, It worked.
Guessingrows= max;
thank you so much and sorry for the mess up.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.