@palolix wrote:
Thank you so much for your great support Tom! I noticed that the cells with numbers on them were in different format in excel so I changed them all to the same format and then I imported the data from a csv file to sas and that solved the problem!
Once you have a CSV file you can avoid using PROC IMPORT and have complete control over how the variables are created. It is especially easy if you want all of the variables to be numeric. This would also allow you to flip/flop the names so that the variable lists would be easier.
Example:
data have;
infile 'myfile.csv' dsd truncover firstobs=2;
input Test Grower Treatment FruitNr
FruitWt_Day0 Color_Day0 Rind_Day0 Button_Day0
TRT_Day3
FruitWt_Day3 Color_Day3 Rind_Day3 Button_Day3
FruitWt_Day7 Color_Day7 Rind_Day7 Button_Day7
Wtloss_Day3 Wtloss_Day7
;
run;
This is great, thank you so much Tom! I noticed I had some issues when using proc import, but this way worked perfectly! I just added a $ after the var TRT_day3 since it is the only one that is not numeric.
@palolix wrote:
This is great, thank you so much Tom! I noticed I had some issues when using proc import, but this way worked perfectly! I just added a $ after the var TRT_day3 since it is the only one that is not numeric.
To give SAS a hint it will use to set the LENGTH of the character variable you can include an informat in the INPUT statement. Just make sure to prefix it with the : modifier so that the INPUT statement still honors the delimiters.
Example:
input .... trt_day3 :$12. ... ;
Good to know, thank you so much Tom for such valuable information!
Thank you very much for your suggestion.
I changed the variable names as you suggested (FruitWt_Day0 etc) and then modified the code to this but I still get the same errors for the array
@palolix wrote:
Thank you very much for your suggestion.
I changed the variable names as you suggested (FruitWt_Day0 etc) and then modified the code to this but I still get the same errors for the array
Changing the name of the variable does not change the variable type. So if you have a mix of character and numeric values as your error messages says then the change has absolutely no effect. The bit about naming similar variables this way is more helpful starting with reading the data initially and making sure that all the variables of the same group are of the same time. Then analysis or manipulation goes quicker.
Thanks for the clarification, I will keep that in mind.
Nearly 200 sessions are now available on demand with the SAS Innovate Digital Pass.
Explore Now →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.