BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Newph
Calcite | Level 5

I am trying to modify a set of code so it can produce varnames with 32 characters, currently its only giving me 20 characters...any help would be greatly appreciated...

 

proc iml; reset noprint; use params;
read all var{variable} into varnames;
read all var _all_ into b;
use Cov1; read all var _num_ into x1;
use Cov2; read all var _num_ into x2;
use CovI; read all var _num_ into x3;

cov = x1 + x2 - x3; /* Calculate covariance matrix */
dfe = b[1,3]; stdb = sqrt(vecdiag(cov)); beta = b[,1]; z = beta/stdb; prob = 1-probf(z#z,1,dfe); /* Calc stats */

print,"Parameter estimates",,varnames[format=$32.] beta[format=8.4] stdb[format=8.4] z[format=8.4] prob[format=8.4];

conc = beta || stdb || z || prob;
cname = {"estimates" "stderror" "zstat" "pvalue"};
create &outdataset from conc [ colname=cname ];
append from conc;

conc = varnames;
cname = {"varnames"};
create names from conc [ colname=cname ];
append from conc;

data &outdataset; merge names &outdataset; run;

quit;

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

Run

proc contents data=params; run;

to view the length of the 'variable' variable. In your IML program, the statement

read all var{variable} into varnames;

means that nleng(varnames) be equal to the length of the 'variable' variable in the PARAMS data set.

If that is the problem, you can use the LENGTH statement in a DATA set to make the variable wider.

 

If you don't have control over the input, you can always resize the CONC variable by using the PUTC function to apply the $32 format, like this:

 

conc = putc(varnames, "$32.");

 

 

View solution in original post

2 REPLIES 2
Rick_SAS
SAS Super FREQ

Run

proc contents data=params; run;

to view the length of the 'variable' variable. In your IML program, the statement

read all var{variable} into varnames;

means that nleng(varnames) be equal to the length of the 'variable' variable in the PARAMS data set.

If that is the problem, you can use the LENGTH statement in a DATA set to make the variable wider.

 

If you don't have control over the input, you can always resize the CONC variable by using the PUTC function to apply the $32 format, like this:

 

conc = putc(varnames, "$32.");

 

 

Newph
Calcite | Level 5

Thanks so much Rick!

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

From The DO Loop
Want more? Visit our blog for more articles like these.
Discussion stats
  • 2 replies
  • 729 views
  • 1 like
  • 2 in conversation