BookmarkSubscribeRSS Feed
mlei_collegeboard_org
Calcite | Level 5
Hi,

I run into something interesting. I have a data set as
qid a b c
DP005205 0.49 -2 0.019
DP005206 0.934 -1.793 0.095
DP005207 0.888 -0.073 0.024.

Then in order to use them in another data set, I put the three records into one record data set as
qqid1 qqid2 qqid3 a1 a2 a3 b1 b2 b3 c1 c2 c3
DP005205 DP005206 DP005207 0.49 0.934 0.888 -2 -1.793 -0.073 0.019 0.095 0.024

In the third data set, I retrieved the one record and tried to put the data in four arrays as qid, a, b, and c and output the result to log to check if the data were correctly retrieved. Following is the related piece of code
if _N_ = 1 then do;
set itemarr;
retain qqid1-qqid%left(&itemno.) a1-a%left(&itemno.) b1-b%left(&itemno.) c1-c%left(&itemno.);
array qqid (*) qqid1-qqid%left(&itemno.);
array a (*) a1-a%left(&itemno.);
array b (*) b1-b%left(&itemno.);
array c (*) c1-c%left(&itemno.);
do i = 1 to &itemno.;
if qqid(i) ne '' then put qqid(i) a(i) b(i) c(i);
end;
end;

The macro variable &itemno.=3 here. But the log shows the retrieved result with two incorrect b values -2 and -0 as
qid a b c
DP005205 0.49 -2 0.019
DP005206 0.934 -2 0.095
DP005207 0.888 -0 0.024

It seems the problem is associated with rounding. But why only these two values cannot be retrieved correctly?

Thanks
Ming
3 REPLIES 3
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
I executed your code as documented, and I do not get the problem - the b1-b3 variables are accurate.

You would benefit from adding some PUTLOG _ALL_; commands in your code to monitor each data step pass.

Scott Barry
SBBWorks, Inc.
mlei_collegeboard_org
Calcite | Level 5
I restarted my SAS and still got the same problem. Did you use SAS version 9? I got the problem solved by adding in the following code before the set statement. But I still don't know why.

informat b 6.3;
format b 6.3;

Thanks!!
Ming
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
I don't see how - SAS-standard formats truncate normally. SAS 9.1.3 SP4 system - both Windows and IBM z/OS (mainframe) flavors. You must have some other code influencing the outcome of your un-transposed output which is not revealed in what you posted, other than the final variable values.

Scott Barry
SBBWorks, Inc.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 614 views
  • 0 likes
  • 2 in conversation