data temperature;
infile '/folders/myfolders/Programs/tempArray.csv' dlm=',' dsd missover;
input temperatureC 2.1;
temperatureF = temperatureC*(9/5)+32;
run;
Hello everyone,
I attached the original data and I wonder if anyone would like to give me some guide on how to read in the whole data?
The log did not show any errors but there is 120 data in it so my output is not correct.
Thanks much!
The informat is incorrect:
input temperatureC 2.1;
Instead, it should be:
input temperatureC 4.;
The width of 4 tells SAS to read 4 characters, and interpret whatever is there as a numeric value.
Instructions of 2.1 would not do the job. That tells SAS to read only 2 characters, and if they contain no decimal point to assume that the last of those characters should be placed after the decimal point.
Are you trying to read all into one column? You have 24 columns but you've only listed one variable in the INPUT statement.
If you're unsure of the type/formats import it first using PROC IMPORT with GUESSINGROWS=MAX and then use the code from the log.
@jc3992 wrote:
data temperature; infile '/folders/myfolders/Programs/tempArray.csv' dlm=',' dsd missover; input temperatureC 2.1; temperatureF = temperatureC*(9/5)+32; run;
Hello everyone,
I attached the original data and I wonder if anyone would like to give me some guide on how to read in the whole data?
The log did not show any errors but there is 120 data in it so my output is not correct.
Thanks much!
The informat is incorrect:
input temperatureC 2.1;
Instead, it should be:
input temperatureC 4.;
The width of 4 tells SAS to read 4 characters, and interpret whatever is there as a numeric value.
Instructions of 2.1 would not do the job. That tells SAS to read only 2 characters, and if they contain no decimal point to assume that the last of those characters should be placed after the decimal point.
Thank you it works.
But there is only 6 obs. in Temp C and temp F
why would this happen?
data temperature; infile '/folders/myfolders/Programs/tempArray.csv' dlm=',' dsd; input temperatureC 4.; temperatureF = temperatureC*(9/5)+32; run; proc print data=temperature; run;
Because you have 24 variables and 5 rows of data, but your code is set up to read one variable.
And since you didn't specify FIRSTOBS=2 it assumed the first row (header row) was data not a header.
got you!
But I added a "@@" behind it would not work.
data temperature; infile '/folders/myfolders/Programs/tempArray.csv' dlm=',' dsd firstobs=2; input temperatureC 4.; temperatureF = temperatureC*(9/5)+32; run; proc print data=temperature; run;
@Reeza was brilliant to ask even what's your exact requirement as I am confused whether you seek clarification on how informats work or the right informats to apply or a code help to read your array data. If its the latter, here you go-
data temperature;
infile 'C:\Users\NSRINIV2\Documents/tempArray.csv' dlm=',' dsd missover firstobs=2;
input temperatureC @;
do while(not missing(temperatureC));
temperatureF = temperatureC*(9/5)+32;
output;
input temperatureC @;
end;
run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.